mirror of https://github.com/espruino/BangleApps
Merge branch 'espruino:master' into master
commit
ad24e33a81
|
@ -36,3 +36,4 @@
|
||||||
0.29: Keep exit at bottom of menu
|
0.29: Keep exit at bottom of menu
|
||||||
Speed up latLonToXY for track rendering
|
Speed up latLonToXY for track rendering
|
||||||
0.30: Minor code improvements
|
0.30: Minor code improvements
|
||||||
|
0.31: Reset draw colours before rendering (to allow black and white maps)
|
|
@ -45,20 +45,22 @@
|
||||||
<div id="map">
|
<div id="map">
|
||||||
</div>
|
</div>
|
||||||
<div id="controls">
|
<div id="controls">
|
||||||
<div style="display:inline-block;text-align:left;vertical-align: top;" id="3bitdiv">
|
<div class="form-group" style="display:inline-block;">
|
||||||
<input type="checkbox" id="3bit"></input><span>3 bit</span>
|
<select class="form-select" id="mapStyle">
|
||||||
<br>
|
<option value="3bit" selected>3 bit</option>
|
||||||
<input type="checkbox" id="preview"><span>Preview</span>
|
<option value="8bit">8 bit</option>
|
||||||
|
<option value="1bit">1 bit</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" style="display:inline-block;">
|
<div class="form-group" style="display:inline-block;">
|
||||||
<select class="form-select" id="mapSize">
|
<select class="form-select" id="mapSize">
|
||||||
<option value="4">Small (4x4)</option>
|
<option value="4">Small (4x4)</option>
|
||||||
<option value="5" selected>Medium (5x5)</option>
|
<option value="5" selected>Medium (5x5)</option>
|
||||||
<option value="7">Large (7x7)</option>
|
<option value="7">Large (7x7)</option>
|
||||||
<option value="10">XL (10x10)</option>
|
<option value="10">XL (10x10)</option>
|
||||||
<option value="15">XXL (15x15)</option>
|
<option value="15">XXL (15x15)</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<button id="getmap" class="btn btn-primary">Get Map</button><button class="btn" onclick="showLoadedMaps()">Map List</button><br/>
|
<button id="getmap" class="btn btn-primary">Get Map</button><button class="btn" onclick="showLoadedMaps()">Map List</button><br/>
|
||||||
<canvas id="maptiles" style="display:none"></canvas>
|
<canvas id="maptiles" style="display:none"></canvas>
|
||||||
<div id="uploadbuttons" style="display:none"><button id="upload" class="btn btn-primary">Upload</button>
|
<div id="uploadbuttons" style="display:none"><button id="upload" class="btn btn-primary">Upload</button>
|
||||||
|
@ -94,20 +96,47 @@ TODO:
|
||||||
var TILELAYER = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
|
var TILELAYER = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||||
var PREVIEWTILELAYER = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
|
var PREVIEWTILELAYER = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||||
|
|
||||||
|
MAPSTYLES = {
|
||||||
|
"3bit" : {
|
||||||
|
layer : 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||||
|
attribution: 'Map data © <a href="https://openstreetmap.org/copyright">OpenStreetMap</a> contributors</a>',
|
||||||
|
img : { compression:false, output:"raw", mode:"3bit",diffusion:"bayer2"}
|
||||||
|
}, "8bit" : {
|
||||||
|
layer : 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||||
|
attribution: 'Map data © <a href="https://openstreetmap.org/copyright">OpenStreetMap</a> contributors</a>',
|
||||||
|
img : { compression:false, output:"raw", mode:"web" }
|
||||||
|
}, "1bit" : {
|
||||||
|
layer : 'https://tiles.stadiamaps.com/tiles/stamen_toner/{z}/{x}/{y}{r}.png',
|
||||||
|
attribution: '© <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a> © <a href="https://www.stamen.com/" target="_blank">Stamen Design</a> © <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a> © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
||||||
|
img : { compression:false, output:"raw", mode:"1bit",inverted:true }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var loadedMaps = [];
|
var loadedMaps = [];
|
||||||
|
|
||||||
// Tiles used for Bangle.js itself
|
// Tiles used for Bangle.js itself
|
||||||
var bangleTileLayer = L.tileLayer(TILELAYER, {
|
var bangleTileLayer;
|
||||||
maxZoom: 18,
|
|
||||||
attribution: 'Map data © <a href="https://openstreetmap.org/copyright">OpenStreetMap</a> contributors</a>'
|
|
||||||
});
|
|
||||||
// Tiles used for the may the user sees (faster)
|
// Tiles used for the may the user sees (faster)
|
||||||
var previewTileLayer = L.tileLayer(PREVIEWTILELAYER, {
|
var previewTileLayer;
|
||||||
maxZoom: 18,
|
// Currently selected version of MAPSTYLES
|
||||||
attribution: 'Map data © <a href="https://openstreetmap.org/copyright">OpenStreetMap</a> contributors</a>'
|
var currentStyle;
|
||||||
});
|
|
||||||
// Could optionally overlay trails: https://wiki.openstreetmap.org/wiki/Tiles
|
// Could optionally overlay trails: https://wiki.openstreetmap.org/wiki/Tiles
|
||||||
|
|
||||||
|
|
||||||
|
function createMapLayers(style) {
|
||||||
|
currentStyle = style;
|
||||||
|
bangleTileLayer = L.tileLayer(style.layer, {
|
||||||
|
maxZoom: 18,
|
||||||
|
attribution: style.attribution
|
||||||
|
});
|
||||||
|
previewTileLayer = L.tileLayer(style.layer, {
|
||||||
|
maxZoom: 18,
|
||||||
|
attribution: style.attribution
|
||||||
|
});
|
||||||
|
}
|
||||||
|
createMapLayers(MAPSTYLES["3bit"]);
|
||||||
|
|
||||||
// Create map and try and set the location to where the browser thinks we are
|
// Create map and try and set the location to where the browser thinks we are
|
||||||
var map = L.map('map').locate({setView: true, maxZoom: 16, enableHighAccuracy:true});
|
var map = L.map('map').locate({setView: true, maxZoom: 16, enableHighAccuracy:true});
|
||||||
previewTileLayer.addTo(map);
|
previewTileLayer.addTo(map);
|
||||||
|
@ -130,10 +159,11 @@ TODO:
|
||||||
if (device && device.info && device.info.g) {
|
if (device && device.info && device.info.g) {
|
||||||
// On 3 bit devices, 3 bit is the best way
|
// On 3 bit devices, 3 bit is the best way
|
||||||
// still allow 8 bit as it makes zoom out much nicer
|
// still allow 8 bit as it makes zoom out much nicer
|
||||||
if (device.info.g.bpp==3) {
|
// ... but lets just default to 3 bit anyway now
|
||||||
|
/*if (device.info.g.bpp==3) {
|
||||||
document.getElementById("3bit").checked = true;
|
document.getElementById("3bit").checked = true;
|
||||||
//document.getElementById("3bitdiv").style = "display:none";
|
//document.getElementById("3bitdiv").style = "display:none";
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
showLoadedMaps();
|
showLoadedMaps();
|
||||||
|
@ -257,17 +287,7 @@ TODO:
|
||||||
|
|
||||||
// convert canvas into an actual tiled image file
|
// convert canvas into an actual tiled image file
|
||||||
function tilesLoaded(ctx, width, height, mapImageFile) {
|
function tilesLoaded(ctx, width, height, mapImageFile) {
|
||||||
var options = {
|
var options = currentStyle.img; // compression options
|
||||||
compression:false, output:"raw",
|
|
||||||
mode:"web"
|
|
||||||
};
|
|
||||||
if (document.getElementById("3bit").checked) {
|
|
||||||
options = {
|
|
||||||
compression:false, output:"raw",
|
|
||||||
mode:"3bit",
|
|
||||||
diffusion:"bayer2"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
/* Go through all the data beforehand and
|
/* Go through all the data beforehand and
|
||||||
turn the saturation up to maximum, so if thresholded to 3 bits it
|
turn the saturation up to maximum, so if thresholded to 3 bits it
|
||||||
works a lot better */
|
works a lot better */
|
||||||
|
@ -289,9 +309,9 @@ TODO:
|
||||||
options.width = TILESIZE;
|
options.width = TILESIZE;
|
||||||
options.height = TILESIZE;
|
options.height = TILESIZE;
|
||||||
var imgstr = imageconverter.RGBAtoString(rgba, options);
|
var imgstr = imageconverter.RGBAtoString(rgba, options);
|
||||||
if (document.getElementById("preview").checked) {
|
/*if (document.getElementById("preview").checked) {
|
||||||
ctx.putImageData(imageData,x*TILESIZE, y*TILESIZE); // write preview
|
ctx.putImageData(imageData,x*TILESIZE, y*TILESIZE); // write preview
|
||||||
}
|
}*/
|
||||||
/*var compress = 'require("heatshrink").decompress('
|
/*var compress = 'require("heatshrink").decompress('
|
||||||
if (!imgstr.startsWith(compress)) throw "Data in wrong format";
|
if (!imgstr.startsWith(compress)) throw "Data in wrong format";
|
||||||
imgstr = imgstr.slice(compress.length,-1);*/
|
imgstr = imgstr.slice(compress.length,-1);*/
|
||||||
|
@ -408,6 +428,14 @@ TODO:
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementById("mapStyle").addEventListener("click", function() {
|
||||||
|
var style = document.getElementById("mapStyle").value;
|
||||||
|
if (!style in MAPSTYLES) return;
|
||||||
|
map.removeLayer(previewTileLayer);
|
||||||
|
createMapLayers(MAPSTYLES[style]);
|
||||||
|
previewTileLayer.addTo(map);
|
||||||
|
});
|
||||||
|
|
||||||
document.getElementById("upload").addEventListener("click", function() {
|
document.getElementById("upload").addEventListener("click", function() {
|
||||||
Util.showModal("Uploading...");
|
Util.showModal("Uploading...");
|
||||||
let promise = Promise.resolve();
|
let promise = Promise.resolve();
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "openstmap",
|
"id": "openstmap",
|
||||||
"name": "OpenStreetMap",
|
"name": "OpenStreetMap",
|
||||||
"shortName": "OpenStMap",
|
"shortName": "OpenStMap",
|
||||||
"version": "0.30",
|
"version": "0.31",
|
||||||
"description": "Loads map tiles from OpenStreetMap onto your Bangle.js and displays a map of where you are. Once installed this also adds map functionality to `GPS Recorder` and `Recorder` apps",
|
"description": "Loads map tiles from OpenStreetMap onto your Bangle.js and displays a map of where you are. Once installed this also adds map functionality to `GPS Recorder` and `Recorder` apps",
|
||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
|
|
|
@ -73,6 +73,7 @@ exports.draw = function() {
|
||||||
}
|
}
|
||||||
var mx = g.getWidth();
|
var mx = g.getWidth();
|
||||||
var my = g.getHeight();
|
var my = g.getHeight();
|
||||||
|
g.setColor(g.theme.fg).setBgColor(g.theme.bg); // reset draw colours
|
||||||
for (var x=ox,ttx=tx; x<mx && ttx<map.w; x+=s,ttx++) {
|
for (var x=ox,ttx=tx; x<mx && ttx<map.w; x+=s,ttx++) {
|
||||||
for (var y=oy,tty=ty;y<my && tty<map.h;y+=s,tty++) {
|
for (var y=oy,tty=ty;y<my && tty<map.h;y+=s,tty++) {
|
||||||
o.frame = ttx+(tty*map.w);
|
o.frame = ttx+(tty*map.w);
|
||||||
|
|
|
@ -11,3 +11,4 @@
|
||||||
0.07: Fix bug with alarms app (scroller) and correctly show images
|
0.07: Fix bug with alarms app (scroller) and correctly show images
|
||||||
0.08: Fix bug with modifying menu - allows hadash to save scroll positions
|
0.08: Fix bug with modifying menu - allows hadash to save scroll positions
|
||||||
0.09: Don't show "..." if a string isn't truncated (i.e. scrolled)
|
0.09: Don't show "..." if a string isn't truncated (i.e. scrolled)
|
||||||
|
0.10: Trigger `remove` callbacks when ending the menu
|
||||||
|
|
|
@ -193,9 +193,11 @@ E.showMenu = function (items) {
|
||||||
mode: "updown",
|
mode: "updown",
|
||||||
back: back,
|
back: back,
|
||||||
remove: function () {
|
remove: function () {
|
||||||
|
var _a;
|
||||||
if (nameScroller)
|
if (nameScroller)
|
||||||
clearInterval(nameScroller);
|
clearInterval(nameScroller);
|
||||||
Bangle.removeListener("swipe", onSwipe);
|
Bangle.removeListener("swipe", onSwipe);
|
||||||
|
(_a = options.remove) === null || _a === void 0 ? void 0 : _a.call(options);
|
||||||
},
|
},
|
||||||
}, function (dir) {
|
}, function (dir) {
|
||||||
if (dir)
|
if (dir)
|
||||||
|
|
|
@ -240,6 +240,7 @@ E.showMenu = (items?: Menu): MenuInstance => {
|
||||||
remove: () => {
|
remove: () => {
|
||||||
if (nameScroller) clearInterval(nameScroller);
|
if (nameScroller) clearInterval(nameScroller);
|
||||||
Bangle.removeListener("swipe", onSwipe);
|
Bangle.removeListener("swipe", onSwipe);
|
||||||
|
options.remove?.();
|
||||||
},
|
},
|
||||||
} as SetUIArg<"updown">,
|
} as SetUIArg<"updown">,
|
||||||
dir => {
|
dir => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "promenu",
|
"id": "promenu",
|
||||||
"name": "Pro Menu",
|
"name": "Pro Menu",
|
||||||
"version": "0.09",
|
"version": "0.10",
|
||||||
"description": "Replace the built in menu function. Supports Bangle.js 1 and Bangle.js 2.",
|
"description": "Replace the built in menu function. Supports Bangle.js 1 and Bangle.js 2.",
|
||||||
"icon": "icon.png",
|
"icon": "icon.png",
|
||||||
"type": "bootloader",
|
"type": "bootloader",
|
||||||
|
|
Loading…
Reference in New Issue