From 40b625c16a1e4468bee49ebb159815fd32f14239 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Mon, 11 Nov 2019 18:40:04 +0000 Subject: [PATCH] add semi-useful code --- testing/README.md | 4 + testing/map/README.md | 3 + testing/map/espruinomap.js | 83 ++++++++++++++++++++ testing/map/maploader.html | 155 +++++++++++++++++++++++++++++++++++++ 4 files changed, 245 insertions(+) create mode 100644 testing/README.md create mode 100644 testing/map/README.md create mode 100644 testing/map/espruinomap.js create mode 100644 testing/map/maploader.html diff --git a/testing/README.md b/testing/README.md new file mode 100644 index 000000000..978eeb560 --- /dev/null +++ b/testing/README.md @@ -0,0 +1,4 @@ +Testing +======= + +Bits of code that could maybe be apps, but that aren't finished yet diff --git a/testing/map/README.md b/testing/map/README.md new file mode 100644 index 000000000..03705019a --- /dev/null +++ b/testing/map/README.md @@ -0,0 +1,3 @@ +This code can take an image file, split it into tiles, and then render those tiles on the watch - making them fit with the GPS data. + +Problem is right now I can't automate getting the rendered area of map, so can't turn it into a very useful tool for BangleApps. diff --git a/testing/map/espruinomap.js b/testing/map/espruinomap.js new file mode 100644 index 000000000..cea770600 --- /dev/null +++ b/testing/map/espruinomap.js @@ -0,0 +1,83 @@ +require("Storage").write('+map',{ + name:"Map", + icon:"*map", + src:"-map" +}); +require("Storage").write('*map',require("heatshrink").decompress(atob("mEwghC/AH4AWh//mcwBZIWI/4ABmYABBZAgIC4oyDBYggIC4wABBYoX/C90imcykYXUkYBB+YyDC5E/F5EykQXKHwYVCL4YXNkQ+BC4wICHgIvJ+QVBC4oYBkUvO5QXCU4wXBF5INCCwqMDAYTXUC6xHNC5Z3LI5UyF6oADF9ZfL+fTAIIUCkUjR5397s9C4LxBC4MykfzDYYvI7vdC4cyDIciO5c97s/C4QABF4IBBC5QvEAAk/+ZdBC5JfEX6XzmaPEa7oX8+AGBgYXHBYQXHBAoXFCowXCEA4yCBZIA/AH4AO"))); + +require("Storage").write("-map",` +var s = require("Storage"); +var hs = require("heatshrink"); +var map = { + imgx : 831, + imgy : 656, + tilesize : 64, + scale : 20000, + lat : 51.7075, + lon : -1.2948 +}; + + +map.center = Bangle.project({lat:map.lat,lon:map.lon}); +var lat = map.lat, lon = map.lon; +var fix = {}; + + +function redraw() { + var cx = g.getWidth()/2; + var cy = g.getHeight()/2; + var p = Bangle.project({lat:lat,lon:lon}); + var ix = (p.x-map.center.x)*4096/map.scale + (map.imgx/2) - cx; + var iy = (map.center.y-p.y)*4096/map.scale + (map.imgy/2) - cy; + //console.log(ix,iy); + var tx = 0|(ix/map.tilesize); + var ty = 0|(iy/map.tilesize); + var ox = (tx*map.tilesize)-ix; + var oy = (ty*map.tilesize)-iy; + for (var x=ox,ttx=tx;x + + + + + + + +

An online map loader for Espruino...

+ Scale
+ Geo URI
+
+
+
+ + +

+
+  
+
+   
+ 
+