Merge pull request #26 from xxDUxx/development

Development
pull/3590/head
xxDUxx 2024-09-25 10:54:28 +02:00 committed by GitHub
commit 8055d1213c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 27 deletions

View File

@ -16,7 +16,7 @@
require('Storage').writeJSON("contourclock.json", settings);
}
require("FontTeletext10x18Ascii").add(Graphics);
let extrasShown = (!settings.hidewhenlocked) && (!Bangle.isLocked());
let extrasShown = (!settings.hidewhenlocked) || (!Bangle.isLocked());
let installedFonts = require('Storage').readJSON("contourclock-install.json") || {};
if (installedFonts.n > 0) { //New install - check for unused font files
settings.fontIndex = E.clip(settings.fontIndex, -installedFonts.n + 1, installedFonts.n - 1);

View File

@ -1,6 +1,6 @@
(function(back) {
var settings = Object.assign({
interval: 5000,
interval: 60000,
}, require('Storage').readJSON("widalt.json", true) || {});
const o=Bangle.getOptions();
Bangle.getPressure().then((p)=>{

View File

@ -1,38 +1,41 @@
(()=>{
var alt="";
var lastAlt=0;
(() => {
var alt = "";
var lastAlt;
var timeout;
var settings = Object.assign({
interval: 5000,
interval: 60000,
}, require('Storage').readJSON("widalt.json", true) || {});
Bangle.setBarometerPower(true,"widalt");
Bangle.on("pressure", (p)=>{
if (Math.floor(p.altitude)!=lastAlt) {
lastAlt=Math.floor(p.altitude);
alt=p.altitude.toFixed(0);
var w = WIDGETS["widalt"].width;
WIDGETS["widalt"].width = 1 + (alt.length)*12+16;
if (w!=WIDGETS["widalt"].width) Bangle.drawWidgets();
else WIDGETS["widalt"].draw();
Bangle.setBarometerPower(true, "widalt");
Bangle.on("pressure", (p) => {
if (timeout) return;
//some other app is using the barometer - ignore new readings until our interval is up
if (Math.floor(p.altitude) != lastAlt) {
lastAlt = Math.floor(p.altitude);
alt = p.altitude.toFixed(0);
WIDGETS.widalt.draw();
}
Bangle.setBarometerPower(false,"widalt")
setTimeout(()=>{Bangle.setBarometerPower(true,"widalt");},settings.interval);
Bangle.setBarometerPower(false, "widalt");
timeout = setTimeout(() => {
timeout = undefined;
Bangle.setBarometerPower(true, "widalt");
}, settings.interval);
});
function draw() {
if (!Bangle.isLCDOn()) return;
if (!Bangle.isLCDOn()) return;
g.reset();
g.setColor(g.theme.bg);
g.fillRect(this.x, this.y, this.x + this.width, this.y + 23);
g.setColor(g.theme.fg);
g.drawImage(atob("EBCBAAAAAAAIAAwgFXAX0BCYIIggTD/EYPZADkACf/4AAAAA"), this.x, this.y+4);
g.setFontCustom(atob("AAAAABwAAOAAAgAAHAADwAD4AB8AB8AA+AAeAADAAAAOAAP+AH/8B4DwMAGBgAwMAGBgAwOAOA//gD/4AD4AAAAAAAABgAAcAwDAGAwAwP/+B//wAAGAAAwAAGAAAAAAAAIAwHgOA4DwMA+BgOwMDmBg4wOeGA/gwDwGAAAAAAAAAGAHA8A4DwMAGBhAwMMGBjgwOcOA+/gDj4AAAAABgAAcAAHgADsAA5gAOMAHBgBwMAP/+B//wABgAAMAAAAAAAgD4OB/AwOYGBjAwMYGBjBwMe8Bh/AIHwAAAAAAAAAfAAP8AHxwB8GAdgwPMGBxgwMOOAB/gAH4AAAAAAABgAAMAABgAwMAeBgPgMHwBj4AN8AB+AAPAABAAAAAAAMfAH38B/xwMcGBhgwMMGBjgwP+OA+/gDj4AAAAAAAAOAAH4AA/gQMMGBgzwME8BhvAOPgA/4AD8AAEAAAAAAGAwA4OAHBwAAA="), 46, atob("BAgMDAwMDAwMDAwMBQ=="), 21+(1<<8)+(1<<16));
g.clearRect(this.x, this.y, this.x + this.width, this.y + 23);
var w = this.width;
this.width = 1 + (alt.length) * 12 + 16;
if (w != this.width) Bangle.drawWidgets();
g.drawImage(atob("EBCBAAAAAAAIAAwgFXAX0BCYIIggTD/EYPZADkACf/4AAAAA"), this.x, this.y + 4);
g.setFontCustom(atob("AAAAABwAAOAAAgAAHAADwAD4AB8AB8AA+AAeAADAAAAOAAP+AH/8B4DwMAGBgAwMAGBgAwOAOA//gD/4AD4AAAAAAAABgAAcAwDAGAwAwP/+B//wAAGAAAwAAGAAAAAAAAIAwHgOA4DwMA+BgOwMDmBg4wOeGA/gwDwGAAAAAAAAAGAHA8A4DwMAGBhAwMMGBjgwOcOA+/gDj4AAAAABgAAcAAHgADsAA5gAOMAHBgBwMAP/+B//wABgAAMAAAAAAAgD4OB/AwOYGBjAwMYGBjBwMe8Bh/AIHwAAAAAAAAAfAAP8AHxwB8GAdgwPMGBxgwMOOAB/gAH4AAAAAAABgAAMAABgAwMAeBgPgMHwBj4AN8AB+AAPAABAAAAAAAMfAH38B/xwMcGBhgwMMGBjgwP+OA+/gDj4AAAAAAAAOAAH4AA/gQMMGBgzwME8BhvAOPgA/4AD8AAEAAAAAAGAwA4OAHBwAAA="), 46, atob("BAgMDAwMDAwMDAwMBQ=="), 21 + (1 << 8) + (1 << 16));
g.setFontAlign(-1, 0);
g.drawString(alt, this.x+16, this.y + 12);
g.drawString(alt, this.x + 16, this.y + 12);
}
WIDGETS["widalt"] = {
WIDGETS.widalt = {
area: "tr",
width: 6,
draw: draw
};
})();