diff --git a/apps.json b/apps.json index 49d1422d9..bfae0931a 100644 --- a/apps.json +++ b/apps.json @@ -447,6 +447,18 @@ {"name": "weather.json"} ] }, + { "id": "chargeanim", + "name": "Charge Animation", + "icon": "icon.png", + "version":"0.01", + "description": "When charging, show a sideways charging animation and keep the screen on. When removed from the charger load the clock again.", + "tags": "battery", + "storage": [ + {"name":"chargeanim.app.js","url":"app.js"}, + {"name":"chargeanim.boot.js","url":"boot.js"}, + {"name":"chargeanim.img","url":"app-icon.js","evaluate":true} + ] + }, { "id": "widbat", "name": "Battery Level Widget", "icon": "widget.png", diff --git a/apps/chargeanim/ChangeLog b/apps/chargeanim/ChangeLog new file mode 100644 index 000000000..5560f00bc --- /dev/null +++ b/apps/chargeanim/ChangeLog @@ -0,0 +1 @@ +0.01: New App! diff --git a/apps/chargeanim/app-icon.js b/apps/chargeanim/app-icon.js new file mode 100644 index 000000000..0252d9ac2 --- /dev/null +++ b/apps/chargeanim/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwxH+AH4A/AH4ASwoAIF/4pZABYuuGDIv/F/4v/F/4vt1Ivt6Zft1Ivu6fNF9nT6a+JF8SNBF9ouBXxQvhFwQvrRoTuLF8BeDXxQvfFwYAFGgwvdRoYAGd840GX84AC5rCLF8ReLF8wMJF8K+CRpAvmNhQvhdwIuKF8SNLF8guLF8JdML8Yv/F/4v/F/4v/GDguYAH4A/AGYA==")) diff --git a/apps/chargeanim/app.js b/apps/chargeanim/app.js new file mode 100644 index 000000000..c2702337a --- /dev/null +++ b/apps/chargeanim/app.js @@ -0,0 +1,28 @@ +g.clear().flip(); +var imgbat = require("heatshrink").decompress(atob("nlWhH+AH4A/AH4AHwoAQHXQ8pHf47rF6YAXHXQ8OHVo8NHf47/Hf47/Hf47/Hf47/Hf47/Hf47r1I766Y756Z351I766ayTHco6BHfCxBHfI6CdyY7jHQQ73WIayUHcQ6DHew6EHeqxEdyo7gOwo70HQqyVHbyxFHeo6GHeY6Hdyo7cWI47zHQ6yWHbY6IHeKxIABa9MHbI6TQJo7YHUI7YWMKzbQKQYOHdYYPHcK9IWJw7sDKA7hHTA7pWKA7qDKQ7gdwwaTHcyxSHcR2ZHcwZUHcqxUHcLuEHSo7kHSw7gWLI7kHS47iHTA7fdwKxYHcQ6ZHb46bO8A76ADg7/Hf47/Hf47/Hf47/Hf47/Hf47/HbY8uHRg8tHRwA/AH4AsA==")); +var imgbubble = require("heatshrink").decompress(atob("ikQhH+AAc0AAgKEAAwRFCpgMDnVerwULCIuCCYoUGCQQQBnQ9MA4Q3GChI5DEpATIJYISKCY46LCYwANCa4UObJ7INeCoSOCpAOI")); + + var W=240,H=240; +var bubbles = []; +for (var i=0;i<10;i++) { + bubbles.push({y:Math.random()*H,ly:0,x:(0.5+(i<5?i:i+8))*W/18,v:0.6+Math.random(),s:0.5+Math.random()}); +} + +function anim() { + /* we don't use any kind of buffering here. Just draw one image + at a time (image contains a background) too, and there is minimal + flicker. */ + var mx = 120, my = 120; + bubbles.forEach(f=>{ + f.y-=f.v;if (f.y<-24) f.y=H+8; + g.drawImage(imgbubble,f.y,f.x,{scale:f.s}); + }); + g.drawImage(imgbat, mx,my,{rotate:Math.sin(getTime()*2)*0.5-Math.PI/2}); + g.flip(); +} + +setInterval(anim,20); + +Bangle.on("charging", isCharging => { + if (!isCharging) load(); +}); diff --git a/apps/chargeanim/boot.js b/apps/chargeanim/boot.js new file mode 100644 index 000000000..cbc78681b --- /dev/null +++ b/apps/chargeanim/boot.js @@ -0,0 +1 @@ +Bangle.on("charging", isCharging => { if (isCharging) load("chargeanim.app.js"); }); diff --git a/apps/chargeanim/icon.png b/apps/chargeanim/icon.png new file mode 100644 index 000000000..9860c323d Binary files /dev/null and b/apps/chargeanim/icon.png differ