clkinfo: added altitude ranges and unfocus on lock
parent
605916ae0a
commit
9ec805c67a
|
|
@ -120,8 +120,10 @@ exports.load = function() {
|
||||||
|
|
||||||
if (Bangle.getPressure){ // Altimeter may not exist
|
if (Bangle.getPressure){ // Altimeter may not exist
|
||||||
bangleItems.push({ name : "Altitude",
|
bangleItems.push({ name : "Altitude",
|
||||||
|
hasRange : true,
|
||||||
get : () => ({
|
get : () => ({
|
||||||
text : alt, v : alt,
|
text : alt, v : parseInt(alt),
|
||||||
|
min : 0, max : 3000,
|
||||||
img : atob("GBiBAAAAAAAAAAAAAAAAAAAAAAACAAAGAAAPAAEZgAOwwAPwQAZgYAwAMBgAGBAACDAADGAABv///////wAAAAAAAAAAAAAAAAAAAA==")
|
img : atob("GBiBAAAAAAAAAAAAAAAAAAAAAAACAAAGAAAPAAEZgAOwwAPwQAZgYAwAMBgAGBAACDAADGAABv///////wAAAAAAAAAAAAAAAAAAAA==")
|
||||||
}),
|
}),
|
||||||
show : function() { this.interval = setInterval(altUpdateHandler, 60000); alt = "--"; altUpdateHandler(); },
|
show : function() { this.interval = setInterval(altUpdateHandler, 60000); alt = "--"; altUpdateHandler(); },
|
||||||
|
|
@ -266,7 +268,14 @@ exports.addInteractive = function(menu, options) {
|
||||||
}
|
}
|
||||||
Bangle.on("swipe",swipeHandler);
|
Bangle.on("swipe",swipeHandler);
|
||||||
var touchHandler;
|
var touchHandler;
|
||||||
|
var lockHandler;
|
||||||
if (options.x!==undefined && options.y!==undefined && options.w && options.h) {
|
if (options.x!==undefined && options.y!==undefined && options.w && options.h) {
|
||||||
|
lockHandler = function() {
|
||||||
|
if(options.focus) {
|
||||||
|
options.focus=false;
|
||||||
|
options.redraw();
|
||||||
|
}
|
||||||
|
};
|
||||||
touchHandler = function(_,e) {
|
touchHandler = function(_,e) {
|
||||||
if (e.x<options.x || e.y<options.y ||
|
if (e.x<options.x || e.y<options.y ||
|
||||||
e.x>(options.x+options.w) || e.y>(options.y+options.h)) {
|
e.x>(options.x+options.w) || e.y>(options.y+options.h)) {
|
||||||
|
|
@ -287,6 +296,7 @@ exports.addInteractive = function(menu, options) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Bangle.on("touch",touchHandler);
|
Bangle.on("touch",touchHandler);
|
||||||
|
Bangle.on("lock", lockHandler);
|
||||||
}
|
}
|
||||||
// draw the first item
|
// draw the first item
|
||||||
menuShowItem(menu[options.menuA].items[options.menuB]);
|
menuShowItem(menu[options.menuA].items[options.menuB]);
|
||||||
|
|
@ -294,6 +304,7 @@ exports.addInteractive = function(menu, options) {
|
||||||
options.remove = function() {
|
options.remove = function() {
|
||||||
Bangle.removeListener("swipe",swipeHandler);
|
Bangle.removeListener("swipe",swipeHandler);
|
||||||
if (touchHandler) Bangle.removeListener("touch",touchHandler);
|
if (touchHandler) Bangle.removeListener("touch",touchHandler);
|
||||||
|
if (lockHandler) Bangle.removeListener("lock", lockHandler);
|
||||||
menuHideItem(menu[options.menuA].items[options.menuB]);
|
menuHideItem(menu[options.menuA].items[options.menuB]);
|
||||||
exports.loadCount--;
|
exports.loadCount--;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue