diff --git a/apps/run/run.app.karvonnen.js b/apps/run/run.app.karvonnen.js new file mode 100644 index 000000000..8d6918a4e --- /dev/null +++ b/apps/run/run.app.karvonnen.js @@ -0,0 +1,28 @@ +Modules.addCached("Layout",ª(){ªp(b,k){ªd(h){h.idž(f[h.id]=h);h.type (h.type="");h.cžh.c.forEach(d)}¯._l=¯.l=b;¯.physBtns=2Šprocess.env.HWVERSION?1:3;¯.options=k {};¯.lazy=¯.options.lazy !1;­a;£(2Œprocess.env.HWVERSION){a=[];ªh(m){"btn"Šm.typeža.push(m);m.cžm.c.forEach(h)}h(b);a.lengthž(¯.physBtns=0,¯.buttons=a,¯.selectedButton=-1)}£(¯.options.btns)£(b=¯.options.btns,¯.physBtns‘b.length){¯.b=b;­h=Math.floor(Bangle.appRect.h/¯.physBtns);§(2<¯.physBtnsž1Šb.lengthžb.unshift({label:""});¯.physBtns>b.length;)b.push({label:""});¯._l.width=g.getWidth()-8;¯._l={type:"h",filly:1,c:[¯._l,{type:"v",pad:1,filly:1,c:b.map(m¢(m.type="txt",m.font="6x8",m.height=h,m.r=1,m))}]}}¤¯._l.width=g.getWidth()-32,¯._l={type:"h",c:[¯._l,{type:"v",c:b.map(h¢(h.type="btn",h.filly=1,h.width=32,h.r=1,h))}]},aža.push.apply(a,¯._l.c[1].c);¯.setUI();¬f=¯;d(¯._l);¯.updateNeeded=!0}ªr(b,k,d,a,f){¬h=¶Šb.bgCol?f:g.toColor(b.bgCol);£(hŒf "txt"Šb.type "btn"Šb.type "img"Šb.type "custom"Šb.type){¬m=b.c;¾b.c;¬c="H"+E.CRC32(E.toJS(b));mž(b.c=m);¾k[c] ((a[c]=[b.x,b.y,b.x+b.w-1,b.y+b.h-1]).bg=¶Šf?g.theme.bg:f,dž(d.push(b),d=¶))}£(b.c)§(¬lÆb.c)r(l,k,d,a,h)}p.prototype.setUI=ª(){Bangle.setUI();­b;¯.buttonsž(Bangle.setUI({mode:"updown",back:¯.options.back},k¢{¬d=¯.selectedButton,a=¯.buttons.length;£(À0‹kž¯.buttons[d])«¯.buttons[d].cb();¯.buttons[d]ž(¾¯.buttons[d].selected,¯.render(¯.buttons[d]));d=(d+a+k)%a;¯.buttons[d]ž(¯.buttons[d].selected=1,¯.render(¯.buttons[d]));¯.selectedButton=d}),b=!0);¯.options.backž!bžBangle.setUI({mode:"custom",back:¯.options.back});£(¯.b){ªk(d,a){.750žstate.notify.dist.nextŽstate.distance){stats["dist"].emit("notify",stats["dist"]);state.notify.dist.next=state.notify.dist.next+state.notify.dist.increment;}});Bangle.on("step",ª(steps){£(!state.active)«;£(stats["step"])stats["step"].emit("changed",stats["step"]);state.stepHistory[0]–steps-state.lastStepCount;state.lastStepCount=steps;£(state.notify.step.increment>0žstate.notify.step.nextŽsteps){stats["step"].emit("notify",stats["step"]);state.notify.step.next=state.notify.step.next+state.notify.step.increment;}});Bangle.on("HRM",ª(h){£(h.confidence‘60){state.BPM=h.bpm;state.BPMage=0;£(state.maxBPM60){state.BPM=0;£(stats["bpm"])stats["bpm"].emit("changed",stats["bpm"]);}£(state.notify.time.increment>0žstate.notify.time.nextŽnow){stats["time"].emit("notify",stats["time"]);state.notify.time.next=state.notify.time.next+state.notify.time.increment;}},1000);ªreset(){state.startTime=Date.now();state.startSteps=state.lastSteps=Bangle.getStepCount();state.lastSteps=0;state.stepHistory.fill(0);state.stepsPerMin=0;state.distance=0;state.avrSpeed=0;state.curSpeed=0;state.BPM=0;state.BPMage=0;state.maxBPM=0;state.alt=·;state.alti=0;state.notify=options.notify;£(options.notify.dist.increment>0){state.notify.dist.next=state.distance+options.notify.dist.increment;}£(options.notify.step.increment>0){state.notify.step.next=state.startSteps+options.notify.step.increment;}£(options.notify.time.increment>0){state.notify.time.next=state.startTime+options.notify.time.increment;}}reset();«{stats:stats,state:state,start:ª(){state.active=´;reset();},stop:ª(){state.active=µ;}};};exports.appendMenuItems=ª(menu,settings,saveSettings){¬paceNames=["1000m","1 mile","1/2 Mthn","Marathon",];¬paceAmts=[1000,1609,21098,42195];menu['Pace']={min:0,max:paceNames.length-1,value:Math.max(paceAmts.indexOf(settings.paceLength),0),format:v¢paceNames[v],onchange:v¢{settings.paceLength=paceAmts[v];saveSettings();},};}exports.appendNotifyMenuItems=ª(menu,settings,saveSettings){¬distNames=['Off',"1000m","1 mile","1/2 Mthn","Marathon",];¬distAmts=[0,1000,1609,21098,42195];menu['Ntfy Dist']={min:0,max:distNames.length-1,value:Math.max(distAmts.indexOf(settings.notify.dist.increment),0),format:v¢distNames[v],onchange:v¢{settings.notify.dist.increment=distAmts[v];saveSettings();},};¬stepNames=['Off','100','500','1000','5000','10000'];¬stepAmts=[0,100,500,1000,5000,10000];menu['Ntfy Steps']={min:0,max:stepNames.length-1,value:Math.max(stepAmts.indexOf(settings.notify.step.increment),0),format:v¢stepNames[v],onchange:v¢{settings.notify.step.increment=stepAmts[v];saveSettings();},};¬timeNames=['Off','30s','1min','2min','5min','10min','30min','1hr'];¬timeAmts=[0,30000,60000,120000,300000,600000,1800000,3600000];menu['Ntfy Time']={min:0,max:timeNames.length-1,value:Math.max(timeAmts.indexOf(settings.notify.time.increment),0),format:v¢timeNames[v],onchange:v¢{settings.notify.time.increment=timeAmts[v];saveSettings();},};};}); +¬ExStats=require("exstats"); +¬B2=process.env.HWVERSION‹2; +¬Layout=require("Layout"); +¬locale=require("locale"); +¬fontHeading="6x8:2"; +¬fontValue=B2?"6x15:2":"6x8:3"; +¬headingCol="#888"; +¬fixCount=0; +¬isMenuDisplayed=µ; +g.clear(); +Bangle.loadWidgets(); +Bangle.drawWidgets(); +­settings=Object.assign({record:´,B1:"dist",B2:"time",B3:"pacea",B4:"bpm",B5:"step",B6:"caden",paceLength:1000,notify:{dist:{value:0,notifications:[],},step:{value:0,notifications:[],},time:{value:0,notifications:[],},},},require("Storage").readJSON("run.json",1) {}); +¬statIDs=[settings.B1,settings.B2,settings.B3,settings.B4,settings.B5,settings.B6].filter(s¢s""); +¬exs=ExStats.getStats(statIDs,settings); +ªonStartStop(){¬running=!exs.state.active;¬prepPromises=[];£(settings.recordžWIDGETS["recorder"]){£(running){isMenuDisplayed=´;prepPromises.push(WIDGETS["recorder"].setRecording(´).then(()¢{isMenuDisplayed=µ;layout.setUI();layout.forgetLazyState();layout.render();}));}¤{prepPromises.push(WIDGETS["recorder"].setRecording(µ));}}£(!prepPromises.length)prepPromises.push(Promise.resolve());Promise.all(prepPromises).then(()¢{£(running){exs.start();}¤{exs.stop();}layout.button.label=running?"STOP":"START";layout.status.label=running?"RUN":"STOP";layout.status.bgCol=running?"#0f0":"#f00";layout.render();});} +¬lc=[]; +§(¬i=0;i0žexs.stats[statType]){configureNotification(exs.stats[statType]);}}); +Bangle.on("GPS",ª(fix){layout.gps.bgCol=fix.fix?"#0f0":"#f00";£(!fix.fix)«;£(fixCount˜‹0){Bangle.buzz();}}); +setInterval(ª(){layout.clock.label=locale.time(¸Date(),1);£(!isMenuDisplayed)layout.render();},1000); \ No newline at end of file