diff --git a/apps/AppDentus/Dentix b/apps/AppDentus/Dentix new file mode 100644 index 000000000..5a026893c --- /dev/null +++ b/apps/AppDentus/Dentix @@ -0,0 +1,94 @@ +var counter = 30; +var counterInterval; +var img = Graphics.createImage(` + + ##### ##### + # ##### # + # # + # # + ## ## + ## ## + ## ## + # #### # + # # # # + # # # # + ## ## + ## ## +`); +var img1 = Graphics.createImage(` + + + ### # ##### ## #### +# # # # # # # +# # ### # # #### +# # # # # # # + ### #### ##### # # # # + + ##### ##### + # ##### # + # # + # # + ## ## + ## ## + ## ## + # #### # + # # # # + # # # # + ## ## + ## ## +`); + + +function outOfTime() { + if (counterInterval) return; + E.showMessage("Out of Time", "My Timer"); + Bangle.buzz(); + Bangle.beep(200, 4000) + .then(() => new Promise(resolve => setTimeout(resolve,200))) + .then(() => Bangle.beep(200, 3000)); + setTimeout(outOfTime, 10000); + g.setColor('#' + Math.floor(Math.random()*16777215).toString(16).padStart(6, '0')); +} + +function immagine(){ + g.drawImage(img1, 90, 20, {scale:2}); +} + +function countDown() { + g.setColor('#012345'); + counter--; + // Out of time + if (counter<=0) { + clearInterval(counterInterval); + counterInterval = undefined; + setWatch(startTimer, (process.env.HWVERSION==2) ? BTN1 : BTN2); + outOfTime(); + return; + } + g.clear(); + g.setFontAlign(0,0); // center font + g.setFont("Vector",80); // vector font, 80px + // draw the current counter value + g.drawImage(img, 90, 20, {scale:2}); + + g.drawString(counter,120,120); + g.drawLine(50,50,180,50); + g.drawLine(50,51,180,51); + g.drawLine(50,52,180,52); + // optional - this keeps the watch LCD lit up + Bangle.setLCDPower(1); + + if(counter<=5){ + immagine(); + } +} + + +function startTimer(){ + counter = 30; + countDown(); + if (!counterInterval) + counterInterval = setInterval(countDown, 1000); +} + +startTimer();