fix regression where apps weren't scanned for modules

pull/563/head
Gordon Williams 2020-09-23 08:51:24 +01:00
parent 23cb4ea18e
commit 811611c51e
2 changed files with 44 additions and 72 deletions

View File

@ -1,82 +1,58 @@
/* jshint esversion: 6 */ // Simple clock from https://www.espruino.com/Bangle.js+Clock
const timeFontSize = 6; // Load fonts
const dateFontSize = 3; require("Font7x11Numeric7Seg").add(Graphics);
const gmtFontSize = 2;
const font = "6x8";
const xyCenter = g.getWidth() / 2;
const yposTime = 75;
const yposDate = 130;
const yposYear = 175;
// Check settings for what type our clock should be // Check settings for what type our clock should be
var is12Hour = (require("Storage").readJSON("setting.json",1)||{})["12hour"]; var is12Hour = (require("Storage").readJSON("setting.json",1)||{})["12hour"];
var d, da, time, hours, minutes, meridian = ""; // position on screen
const X = 160, Y = 140;
function drawSimpleClock() { function draw() {
// get date // work out how to display the current time
var d = new Date(); var d = new Date();
var da = d.toString().split(" "); var h = d.getHours(), m = d.getMinutes();
g.reset(); // default draw styles
// drawSting centered
g.setFontAlign(0, 0);
// draw time
var time = da[4].substr(0, 5).split(":");
var hours = time[0],
minutes = time[1];
var meridian = "";
if (is12Hour) { if (is12Hour) {
hours = parseInt(hours,10); if (h == 0) h = 12;
meridian = "AM"; else if (h>12) h -= 12;
if (hours == 0) {
hours = 12;
meridian = "AM";
} else if (hours >= 12) {
meridian = "PM";
if (hours>12) hours -= 12;
}
hours = (" "+hours).substr(-2);
} }
var time = (" "+h).substr(-2) + ":" + ("0"+m).substr(-2);
g.setFont(font, timeFontSize); // Reset the state of the graphics library
g.drawString(`${hours}:${minutes}`, xyCenter, yposTime, true); g.reset();
g.setFont(font, gmtFontSize); // draw the current time (4x size 7 segment)
g.drawString(meridian, xyCenter + 102, yposTime + 10, true); g.setFont("7x11Numeric7Seg",4);
g.setFontAlign(1,1); // align right bottom
// draw Day, name of month, Date g.drawString(time, X, Y, true /*clear background*/);
var date = [da[0], da[1], da[2]].join(" "); // draw the seconds (2x size 7 segment)
g.setFont(font, dateFontSize); g.setFont("7x11Numeric7Seg",2);
g.drawString(("0"+d.getSeconds()).substr(-2), X+30, Y, true /*clear background*/);
g.drawString(date, xyCenter, yposDate, true); // draw the date, in a normal font
g.setFont("6x8");
// draw year g.setFontAlign(0,1); // align center bottom
g.setFont(font, dateFontSize); // pad the date - this clears the background if the date were to change length
g.drawString(d.getFullYear(), xyCenter, yposYear, true); var dateStr = " "+require("locale").date(d)+" ";
g.drawString(dateStr, g.getWidth()/2, Y+15, true /*clear background*/);
// draw gmt
var gmt = da[5];
g.setFont(font, gmtFontSize);
g.drawString(gmt, xyCenter, yposGMT, true);
} }
// handle switch display on by pressing BTN1 // Clear the screen once, at startup
Bangle.on('lcdPower', function(on) {
if (on) drawSimpleClock();
});
// clean app screen
g.clear(); g.clear();
// draw immediately at first
draw();
var secondInterval = setInterval(draw, 1000);
// Stop updates when LCD is off, restart when on
Bangle.on('lcdPower',on=>{
if (secondInterval) clearInterval(secondInterval);
secondInterval = undefined;
if (on) {
secondInterval = setInterval(draw, 1000);
draw(); // draw immediately
}
});
// Load widgets
Bangle.loadWidgets(); Bangle.loadWidgets();
Bangle.drawWidgets(); Bangle.drawWidgets();
// Show launcher when middle button pressed
setWatch(Bangle.showLauncher, BTN2, { repeat: false, edge: "falling" });
// refesh every 15 sec // ====================================== Vibration
setInterval(drawSimpleClock, 15E3);
// draw now
drawSimpleClock();
// vibrate 0..9 // vibrate 0..9
function vibrateDigit(num) { function vibrateDigit(num) {
if (num==0) return Bangle.buzz(500); if (num==0) return Bangle.buzz(500);
@ -117,9 +93,5 @@ function vibrateTime() {
then(() => vibrateBusy=false); then(() => vibrateBusy=false);
} }
// Show launcher when middle button pressed
setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"});
// when BTN1 pressed, vibrate // when BTN1 pressed, vibrate
setWatch(vibrateTime, BTN1, {repeat:true,edge:"rising"}); setWatch(vibrateTime, BTN1, {repeat:true,edge:"rising"});

2
core

@ -1 +1 @@
Subproject commit 9708e1a15ee20734a24f6f2913078aa8bba625dc Subproject commit c99967381280f483877c3f11ae7b0d4dc8c53e0e