Merge branch 'espruino:master' into master
commit
bb06107b97
|
|
@ -197,9 +197,8 @@ module.exports = {
|
|||
]
|
||||
},
|
||||
"apps/sixths/sixths.app.js": {
|
||||
"hash": "b4572a529b31a5edcbd6ca5843b91c54abcbf75b2a28e90bd33751f7d6a3ebcd",
|
||||
"hash": "2a4676828bdf78df052df402de34e6f1abd1c847ebe0d193fc789cd6e9dd0e5c",
|
||||
"rules": [
|
||||
"no-unused-vars",
|
||||
"no-undef"
|
||||
]
|
||||
},
|
||||
|
|
@ -1161,12 +1160,6 @@ module.exports = {
|
|||
"no-undef"
|
||||
]
|
||||
},
|
||||
"apps/contacts/contacts.app.js": {
|
||||
"hash": "f105adae91ef5bb79266bd20b8f1f5aaebe9863853c714d1f2b22c97d9ff7773",
|
||||
"rules": [
|
||||
"no-undef"
|
||||
]
|
||||
},
|
||||
"apps/calendar/settings.js": {
|
||||
"hash": "9f05366b91d0293ed965d8de019bfd044f96683542b86ebabaa3c8d3cc3ad3a7",
|
||||
"rules": [
|
||||
|
|
|
|||
|
|
@ -14,3 +14,4 @@
|
|||
0.09: Fix scrolling to last line for long text
|
||||
0.10: Track Listeners added with prependListener
|
||||
Handle changed internal callback variable name for watches introduced in 2v21.104
|
||||
0.11: Update for new setLCDOverlay remove handler
|
||||
|
|
@ -55,7 +55,7 @@ const show = function(){
|
|||
if (ovr.getBPP() == 1) {
|
||||
img.palette = new Uint16Array([g.theme.fg,g.theme.bg]);
|
||||
}
|
||||
Bangle.setLCDOverlay(img, ovrx, ovry);
|
||||
Bangle.setLCDOverlay(img, ovrx, ovry, {id:"messagesoverlay", remove:cleanup});
|
||||
};
|
||||
|
||||
const manageEvent = function(event) {
|
||||
|
|
@ -618,7 +618,7 @@ const cleanup = function(){
|
|||
}
|
||||
restoreHandlers();
|
||||
|
||||
Bangle.setLCDOverlay();
|
||||
Bangle.setLCDOverlay(undefined, {id: "messagesoverlay"});
|
||||
ovr = undefined;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "messagesoverlay",
|
||||
"name": "Messages Overlay",
|
||||
"version": "0.10",
|
||||
"version": "0.11",
|
||||
"description": "An overlay based implementation of a messages UI (display notifications from iOS and Gadgetbridge/Android)",
|
||||
"icon": "app.png",
|
||||
"type": "bootloader",
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
0.01: attempt to import
|
||||
0.02: better GPS support, adding altitude and temperature support
|
||||
0.03: Minor code improvements
|
||||
0.03: minor code improvements
|
||||
0.04: make height auto-calibration useful and slow ticks to save power
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{ "id": "sixths",
|
||||
"name": "Sixth sense",
|
||||
"version": "0.03",
|
||||
"version": "0.04",
|
||||
"description": "Clock for outdoor use with GPS support",
|
||||
"icon": "app.png",
|
||||
"readme": "README.md",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// Sixth sense
|
||||
/* eslint-disable no-unused-vars */
|
||||
|
||||
// Options you'll want to edit
|
||||
const rest_altitude = 354;
|
||||
|
|
@ -7,13 +8,13 @@ const geoid_to_sea_level = 0; // Maybe BangleJS2 already compensates?
|
|||
const W = g.getWidth();
|
||||
const H = g.getHeight();
|
||||
|
||||
var cx = 100; cy = 105; sc = 70;
|
||||
temp = 0; alt = 0; bpm = 0;
|
||||
var cx = 100, cy = 105, sc = 70,
|
||||
temp = 0, alt = 0, bpm = 0;
|
||||
var buzz = "", /* Set this to transmit morse via vibrations */
|
||||
inm = "", l = "", /* For incoming morse handling */
|
||||
in_str = "",
|
||||
note = "(NOTEHERE)",
|
||||
debug = "v930", debug2 = "(otherdb)", debug3 = "(short)";
|
||||
debug = "v1119", debug2 = "(otherdb)", debug3 = "(short)";
|
||||
var mode = 0, mode_time = 0; // 0 .. normal, 1 .. note, 2.. mark name
|
||||
var disp_mode = 0; // 0 .. normal, 1 .. small time
|
||||
|
||||
|
|
@ -30,29 +31,29 @@ var gps_dist = 0;
|
|||
var mark_heading = -1;
|
||||
|
||||
// Is the human present?
|
||||
var is_active = false, last_active = getTime();
|
||||
var is_active = false, last_active = getTime() - 14*60, last_unlocked = getTime();
|
||||
var draw_dot = false;
|
||||
var is_level = false;
|
||||
|
||||
// For altitude handling.
|
||||
var cur_altitude = 0;
|
||||
var cur_temperature = 0, alt_adjust = 0;
|
||||
var alt_adjust_mode = "";
|
||||
var cur_temperature = 0;
|
||||
|
||||
// Marks
|
||||
var cur_mark = null;
|
||||
|
||||
// Icons
|
||||
|
||||
icon_alt = "\0\x08\x1a\1\x00\x00\x00\x20\x30\x78\x7C\xFE\xFF\x00\xC3\xE7\xFF\xDB\xC3\xC3\xC3\xC3\x00\x00\x00\x00\x00\x00\x00\x00";
|
||||
icon_m = "\0\x08\x1a\1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xC3\xE7\xFF\xDB\xC3\xC3\xC3\xC3\x00\x00\x00\x00\x00\x00\x00\x00";
|
||||
icon_km = "\0\x08\x1a\1\xC3\xC6\xCC\xD8\xF0\xD8\xCC\xC6\xC3\x00\xC3\xE7\xFF\xDB\xC3\xC3\xC3\xC3\x00\x00\x00\x00\x00\x00\x00\x00";
|
||||
icon_kph = "\0\x08\x1a\1\xC3\xC6\xCC\xD8\xF0\xD8\xCC\xC6\xC3\x00\xC3\xE7\xFF\xDB\xC3\xC3\xC3\xC3\x00\xFF\x00\xC3\xC3\xFF\xC3\xC3";
|
||||
icon_c = "\0\x08\x1a\1\x00\x00\x60\x90\x90\x60\x00\x7F\xFF\xC0\xC0\xC0\xC0\xC0\xFF\x7F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
|
||||
var icon_alt = "\0\x08\x1a\1\x00\x00\x00\x20\x30\x78\x7C\xFE\xFF\x00\xC3\xE7\xFF\xDB\xC3\xC3\xC3\xC3\x00\x00\x00\x00\x00\x00\x00\x00";
|
||||
var icon_m = "\0\x08\x1a\1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xC3\xE7\xFF\xDB\xC3\xC3\xC3\xC3\x00\x00\x00\x00\x00\x00\x00\x00";
|
||||
var icon_km = "\0\x08\x1a\1\xC3\xC6\xCC\xD8\xF0\xD8\xCC\xC6\xC3\x00\xC3\xE7\xFF\xDB\xC3\xC3\xC3\xC3\x00\x00\x00\x00\x00\x00\x00\x00";
|
||||
var icon_kph = "\0\x08\x1a\1\xC3\xC6\xCC\xD8\xF0\xD8\xCC\xC6\xC3\x00\xC3\xE7\xFF\xDB\xC3\xC3\xC3\xC3\x00\xFF\x00\xC3\xC3\xFF\xC3\xC3";
|
||||
var icon_c = "\0\x08\x1a\1\x00\x00\x60\x90\x90\x60\x00\x7F\xFF\xC0\xC0\xC0\xC0\xC0\xFF\x7F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
|
||||
|
||||
function toMorse(x) {
|
||||
r = "";
|
||||
var r = "";
|
||||
for (var i = 0; i < x.length; i++) {
|
||||
c = x[i];
|
||||
var c = x[i];
|
||||
if (c == " ") {
|
||||
r += " ";
|
||||
continue;
|
||||
|
|
@ -61,8 +62,15 @@ function toMorse(x) {
|
|||
}
|
||||
return r;
|
||||
}
|
||||
function doBuzz(s) {
|
||||
if (buzz == "") {
|
||||
buzz = s;
|
||||
buzzTask();
|
||||
} else
|
||||
buzz += s;
|
||||
}
|
||||
function aload(s) {
|
||||
buzz += toMorse(' E');
|
||||
doBuzz(toMorse(' E'));
|
||||
load(s);
|
||||
}
|
||||
function gpsRestart() {
|
||||
|
|
@ -102,7 +110,7 @@ function fmtTimeDiff(d) {
|
|||
function gpsHandleFix(fix) {
|
||||
if (!prev_fix) {
|
||||
show("GPS acquired", 10);
|
||||
buzz += " .";
|
||||
doBuzz(" .");
|
||||
prev_fix = fix;
|
||||
}
|
||||
if (0) {
|
||||
|
|
@ -110,18 +118,15 @@ function gpsHandleFix(fix) {
|
|||
alt_adjust = cur_altitude - (fix.alt + geoid_to_sea_level);
|
||||
alt_adjust_mode = "g";
|
||||
}
|
||||
if (1) {
|
||||
debug = ""+fix.alt+"m "+alt_adjust;
|
||||
}
|
||||
if (1) {
|
||||
let now1 = Date();
|
||||
let now2 = fix.time;
|
||||
n1 = now1.getMinutes() * 60 + now1.getSeconds();
|
||||
n2 = now2.getMinutes() * 60 + now2.getSeconds();
|
||||
var n1 = now1.getMinutes() * 60 + now1.getSeconds();
|
||||
var n2 = now2.getMinutes() * 60 + now2.getSeconds();
|
||||
debug2 = "te "+(n2-n1)+"s";
|
||||
}
|
||||
loggps(fix);
|
||||
d = calcDistance(fix, prev_fix);
|
||||
var d = calcDistance(fix, prev_fix);
|
||||
if (d > 30) {
|
||||
prev_fix = fix;
|
||||
gps_dist += d/1000;
|
||||
|
|
@ -130,7 +135,7 @@ function gpsHandleFix(fix) {
|
|||
function gpsHandle() {
|
||||
let msg = "";
|
||||
if (!last_restart) {
|
||||
d = (getTime()-last_pause);
|
||||
var d = (getTime()-last_pause);
|
||||
if (last_fix)
|
||||
msg = "PL"+ fmtTimeDiff(getTime()-last_fix);
|
||||
else
|
||||
|
|
@ -141,12 +146,12 @@ function gpsHandle() {
|
|||
gpsRestart();
|
||||
}
|
||||
} else {
|
||||
fix = Bangle.getGPSFix();
|
||||
var fix = Bangle.getGPSFix();
|
||||
if (fix && fix.fix && fix.lat) {
|
||||
gpsHandleFix(fix);
|
||||
msg = fix.speed.toFixed(1) + icon_kph;
|
||||
print("GPS FIX", msg);
|
||||
|
||||
|
||||
if (!last_fstart)
|
||||
last_fstart = getTime();
|
||||
last_fix = getTime();
|
||||
|
|
@ -162,10 +167,10 @@ function gpsHandle() {
|
|||
}
|
||||
}
|
||||
|
||||
d = (getTime()-last_restart);
|
||||
d2 = (getTime()-last_fstart);
|
||||
var d = (getTime()-last_restart);
|
||||
var d2 = (getTime()-last_fstart);
|
||||
print("gps on, restarted ", d, gps_needed, d2, fix.lat);
|
||||
if (getTime() > gps_speed_limit &&
|
||||
if (getTime() > gps_speed_limit &&
|
||||
(d > gps_needed || (last_fstart && d2 > 10))) {
|
||||
gpsPause();
|
||||
gps_needed = gps_needed * 1.5;
|
||||
|
|
@ -187,7 +192,7 @@ function markNew() {
|
|||
}
|
||||
function markHandle() {
|
||||
let m = cur_mark;
|
||||
msg = m.name + ">" + fmtTimeDiff(getTime()- m.time);
|
||||
var msg = m.name + ">" + fmtTimeDiff(getTime()- m.time);
|
||||
if (m.fix && m.fix.fix) {
|
||||
let s = fmtDist(calcDistance(m.fix, prev_fix)/1000) + icon_km;
|
||||
msg += " " + s;
|
||||
|
|
@ -201,7 +206,7 @@ function markHandle() {
|
|||
}
|
||||
function entryDone() {
|
||||
show(":" + in_str);
|
||||
buzz += " .";
|
||||
doBuzz(" .");
|
||||
switch (mode) {
|
||||
case 1: logstamp(">" + in_str); break;
|
||||
case 2: cur_mark.name = in_str; break;
|
||||
|
|
@ -227,18 +232,18 @@ function inputHandler(s) {
|
|||
switch(s) {
|
||||
case 'B':
|
||||
s = ' B';
|
||||
bat = E.getBattery();
|
||||
var bat = E.getBattery();
|
||||
if (bat > 45)
|
||||
s += 'E';
|
||||
else
|
||||
s = s+(bat/5);
|
||||
buzz += toMorse(s);
|
||||
doBuzz(toMorse(s));
|
||||
show("Bat "+bat+"%", 60);
|
||||
break;
|
||||
case 'F': gpsOff(); show("GPS off", 3); break;
|
||||
case 'G': gpsOn(); gps_limit = getTime() + 60*60*4; show("GPS on", 3); break;
|
||||
case 'I':
|
||||
disp_mode += 1;
|
||||
disp_mode += 1;
|
||||
if (disp_mode == 2) {
|
||||
disp_mode = 0;
|
||||
}
|
||||
|
|
@ -250,13 +255,13 @@ function inputHandler(s) {
|
|||
case 'S': gpsOn(); gps_limit = getTime() + 60*30; gps_speed_limit = gps_limit; show("GPS on", 3); break;
|
||||
case 'T':
|
||||
s = ' T';
|
||||
d = new Date();
|
||||
var d = new Date();
|
||||
s += d.getHours() % 10;
|
||||
s += add0(d.getMinutes());
|
||||
buzz += toMorse(s);
|
||||
doBuzz(toMorse(s));
|
||||
break;
|
||||
case 'R': aload("run.app.js"); break;
|
||||
case 'Y': buzz += " ."; Bangle.resetCompass(); break;
|
||||
case 'Y': doBuzz(buzz); Bangle.resetCompass(); break;
|
||||
}
|
||||
}
|
||||
const morseDict = {
|
||||
|
|
@ -352,7 +357,7 @@ function touchHandler(d) {
|
|||
if (x > W/2 && y > H/2 && l != "-d") {
|
||||
inm = inm + "-";
|
||||
l = "-d";
|
||||
}
|
||||
}
|
||||
|
||||
//print(inm, "drag:", d);
|
||||
}
|
||||
|
|
@ -373,9 +378,9 @@ function loggps(fix) {
|
|||
}
|
||||
function hourly() {
|
||||
print("hourly");
|
||||
s = ' T';
|
||||
var s = ' T';
|
||||
if (is_active)
|
||||
buzz += toMorse(s);
|
||||
doBuzz(toMorse(s));
|
||||
logstamp("");
|
||||
}
|
||||
function show(msg, timeout) {
|
||||
|
|
@ -383,11 +388,11 @@ function show(msg, timeout) {
|
|||
}
|
||||
function fivemin() {
|
||||
print("fivemin");
|
||||
s = ' B';
|
||||
bat = E.getBattery();
|
||||
var s = ' B';
|
||||
var bat = E.getBattery();
|
||||
if (bat < 25) {
|
||||
if (is_active)
|
||||
buzz += toMorse(s);
|
||||
doBuzz(toMorse(s));
|
||||
show("Bat "+bat+"%", 60);
|
||||
}
|
||||
try {
|
||||
|
|
@ -397,7 +402,7 @@ function fivemin() {
|
|||
} catch (e) {
|
||||
print("Altimeter error", e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
function every(now) {
|
||||
if ((mode > 0) && (getTime() - mode_time > 10)) {
|
||||
|
|
@ -465,7 +470,7 @@ function drawDot(h, d, s) {
|
|||
g.fillCircle(x,y, 10);
|
||||
}
|
||||
function drawBackground() {
|
||||
acc = Bangle.getAccel();
|
||||
var acc = Bangle.getAccel();
|
||||
is_level = (acc.z < -0.95);
|
||||
if (is_level) {
|
||||
let obj = Bangle.getCompass();
|
||||
|
|
@ -486,12 +491,23 @@ function drawBackground() {
|
|||
}
|
||||
}
|
||||
function drawTime(now) {
|
||||
if (disp_mode == 0)
|
||||
if (disp_mode == 0)
|
||||
g.setFont('Vector', 60);
|
||||
else
|
||||
g.setFont('Vector', 26);
|
||||
g.setFont('Vector', 26);
|
||||
g.setFontAlign(1, 1);
|
||||
g.drawString(now.getHours() + ":" + add0(now.getMinutes()), W, 90);
|
||||
draw_dot = !draw_dot;
|
||||
let dot = ":";
|
||||
if (!draw_dot)
|
||||
dot = ".";
|
||||
g.drawString(now.getHours() + dot + add0(now.getMinutes()), W, 90);
|
||||
}
|
||||
function adjPressure(a) {
|
||||
var o = Bangle.getOptions();
|
||||
print(o);
|
||||
o.seaLevelPressure = o.seaLevelPressure * m + a;
|
||||
Bangle.setOptions(o);
|
||||
var avr = [];
|
||||
}
|
||||
function draw() {
|
||||
if (disp_mode == 2) {
|
||||
|
|
@ -530,26 +546,36 @@ function draw() {
|
|||
+ fmtSteps(Bangle.getHealthStatus("day").steps), 10, 115);
|
||||
|
||||
g.drawString(msg, 10, 145);
|
||||
|
||||
|
||||
if (getTime() - last_active > 15*60) {
|
||||
alt_adjust = cur_altitude - rest_altitude;
|
||||
alt_adjust_mode = "h";
|
||||
msg = "H)" + fmtAlt(alt_adjust);
|
||||
let alt_adjust = cur_altitude - rest_altitude;
|
||||
let abs = Math.abs(alt_adjust);
|
||||
print("adj", alt_adjust);
|
||||
var o = Bangle.getOptions();
|
||||
if (abs > 10 && abs < 150) {
|
||||
let a = 0.01;
|
||||
// FIXME: draw is called often compared to alt reading
|
||||
if (cur_altitude > rest_altitude)
|
||||
a = -a;
|
||||
o.seaLevelPressure = o.seaLevelPressure + a;
|
||||
Bangle.setOptions(o);
|
||||
}
|
||||
msg = o.seaLevelPressure.toFixed(1) + "hPa";
|
||||
} else {
|
||||
msg = alt_adjust_mode+")"+fmtAlt(cur_altitude - alt_adjust);
|
||||
msg = fmtAlt(cur_altitude);
|
||||
}
|
||||
msg = msg + " " + cur_temperature.toFixed(1)+icon_c;
|
||||
if (cur_mark) {
|
||||
msg = markHandle();
|
||||
}
|
||||
g.drawString(msg, 10, 175);
|
||||
|
||||
|
||||
if (disp_mode == 1) {
|
||||
g.drawString(debug, 10, 45);
|
||||
g.drawString(debug2, 10, 65);
|
||||
g.drawString(debug3, 10, 85);
|
||||
}
|
||||
|
||||
|
||||
queueDraw();
|
||||
}
|
||||
function draw_all() {
|
||||
|
|
@ -562,16 +588,16 @@ function draw_all() {
|
|||
let now = new Date();
|
||||
g.drawString(now.getHours() + ":" + add0(now.getMinutes()) + ":" + add0(now.getSeconds()), 10, 40);
|
||||
|
||||
acc = Bangle.getAccel();
|
||||
var acc = Bangle.getAccel();
|
||||
let ax = 0 + acc.x, ay = 0.75 + acc.y, az = 0.75 + acc.y;
|
||||
let diff = ax * ax + ay * ay + az * az;
|
||||
diff = diff * 3;
|
||||
if (diff > 1)
|
||||
diff = 1;
|
||||
|
||||
co = Bangle.getCompass();
|
||||
step = Bangle.getStepCount();
|
||||
bat = E.getBattery();
|
||||
var co = Bangle.getCompass();
|
||||
var step = Bangle.getStepCount();
|
||||
var bat = E.getBattery();
|
||||
Bangle.getPressure().then((x) => { alt = x.altitude; temp = x.temperature; },
|
||||
print);
|
||||
|
||||
|
|
@ -609,22 +635,23 @@ function draw_all() {
|
|||
queueDraw();
|
||||
}
|
||||
function accelTask() {
|
||||
tm = 100;
|
||||
acc = Bangle.getAccel();
|
||||
en = !Bangle.isLocked();
|
||||
var tm = 100;
|
||||
var acc = Bangle.getAccel();
|
||||
var en = !Bangle.isLocked();
|
||||
var msg;
|
||||
if (en && acc.z < -0.95) {
|
||||
msg = "Level";
|
||||
buzz = ".-..";
|
||||
doBuzz(".-..");
|
||||
tm = 3000;
|
||||
}
|
||||
if (en && acc.x < -0.80) {
|
||||
msg = "Down";
|
||||
buzz = "-..";
|
||||
doBuzz("-..");
|
||||
tm = 3000;
|
||||
}
|
||||
if (en && acc.x > 0.95) {
|
||||
msg = "Up";
|
||||
buzz = "..-";
|
||||
doBuzz("..-");
|
||||
tm = 3000;
|
||||
}
|
||||
|
||||
|
|
@ -632,9 +659,9 @@ function accelTask() {
|
|||
}
|
||||
function buzzTask() {
|
||||
if (buzz != "") {
|
||||
now = buzz[0];
|
||||
var now = buzz[0];
|
||||
buzz = buzz.substring(1);
|
||||
dot = 100;
|
||||
var dot = 100;
|
||||
if (now == " ") {
|
||||
setTimeout(buzzTask, 300);
|
||||
} else if (now == ".") {
|
||||
|
|
@ -646,8 +673,7 @@ function buzzTask() {
|
|||
} else if (now == "/") {
|
||||
setTimeout(buzzTask, 6*dot);
|
||||
} else print("Unknown character -- ", now, buzz);
|
||||
} else
|
||||
setTimeout(buzzTask, 1000);
|
||||
}
|
||||
}
|
||||
function aliveTask() {
|
||||
function cmp(s) {
|
||||
|
|
@ -666,26 +692,33 @@ function aliveTask() {
|
|||
|
||||
setTimeout(aliveTask, 60000);
|
||||
}
|
||||
|
||||
var drawTimeout;
|
||||
function lockHandler(locked) {
|
||||
if (!locked) {
|
||||
last_unlocked = getTime();
|
||||
draw();
|
||||
}
|
||||
}
|
||||
|
||||
function queueDraw() {
|
||||
if (drawTimeout) clearTimeout(drawTimeout);
|
||||
if (0) // FIXME
|
||||
if (getTime() - last_unlocked > 5*60)
|
||||
next = 60000;
|
||||
else
|
||||
next = 1000;
|
||||
drawTimeout = setTimeout(function() {
|
||||
drawTimeout = undefined;
|
||||
draw();
|
||||
}, next - (Date.now() % next));
|
||||
|
||||
setTimeout(draw, next - (Date.now() % next));
|
||||
}
|
||||
function start() {
|
||||
g.reset();
|
||||
Bangle.setUI({
|
||||
mode : "clock"
|
||||
});
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
|
||||
Bangle.on("drag", touchHandler);
|
||||
Bangle.on("lock", lockHandler);
|
||||
if (0)
|
||||
Bangle.on("accel", accelHandler);
|
||||
if (1) {
|
||||
if (0) {
|
||||
Bangle.setCompassPower(1, "sixths");
|
||||
Bangle.setBarometerPower(1, "sixths");
|
||||
}
|
||||
|
|
@ -705,12 +738,6 @@ function start() {
|
|||
}
|
||||
}
|
||||
|
||||
g.reset();
|
||||
Bangle.setUI({
|
||||
mode : "clock"
|
||||
});
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
let logfile = require("Storage").open("sixths.egt", "a");
|
||||
|
||||
if (0) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
0.01: New App!
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
# SUPACLOCK Pro ULTRA
|
||||
|
||||
A nice clock, with four ClockInfo areas at the bottom. Tap them and swipe up/down and left/right to toggle between different information.
|
||||
|
||||
- Supports Light and Dark Themes.
|
||||
- It has a useless splash-screen for increased ULTRAness
|
||||
- Lazy Loading of Clock-Info, shows clock-face faster
|
||||
- Uses locale module to display of day and month
|
||||
|
||||
|
||||
Based on [LCD Clock Plus](https://banglejs.com/apps/?id=lcdclockplus)
|
||||
|
||||
## Screenshots
|
||||
|
||||
Light theme
|
||||
|
||||

|
||||
|
||||
Dark theme
|
||||
|
||||

|
||||
|
||||
## Credits
|
||||
|
||||
Written by devsnd
|
||||
|
|
@ -0,0 +1 @@
|
|||
atob("MDAB/////////////////////////////////gX2D8H//f328z3//f32+v3//AX2+v3///X2BgH///bm/v3/+A8e/v3//////////hf4/C+/+ffnM+5/+/ff1+3/+/ff1+H/+/ff1+7/+ffvt+9//BAweC+//////////4B//////AAf////+P+P////8+fH////48/H////45/H////8R/F////8x+A/////j8A/8H//j4APwD//AAYDjD//EA5HHD/+EByOHDf+EDkOGCf8OfkAAA/8P/4AAB/4P/8AAD/4f/8HAP/+///////////////55OAADx/55OTBxh/55OTD5k/55PTQDM/55PzxnAf4BAzzyOf8DAT7yff////////")
|
||||
|
|
@ -0,0 +1,195 @@
|
|||
{ // must be inside our own scope here so that when we are unloaded everything disappears
|
||||
// we also define functions using 'let fn = function() {..}' for the same reason. function decls are globalj
|
||||
let removeHasNotRun = true;
|
||||
let drawTimeout;
|
||||
|
||||
const supaClockImg = {
|
||||
width : 95, height : 13, bpp : 1,
|
||||
buffer : atob("wL7B+Dhf4/C+4P//f328z0+/OZ9zPv/+/vt9fr99/X7e3f/8Bfb6/X77+vw9e///6+wMAv339fu+4DD/25v79Pv32/e4HNvAePf37BAweC+3+7f////////////P4B////////////////////////////7UEYf///////////2qrW////////////tdxh////////////iLtaA="),
|
||||
palette: new Uint16Array(g.theme.dark ? [g.toColor("#fff"), 0] : [0, g.toColor("#fff")]),
|
||||
}
|
||||
// todo
|
||||
// const is12Hour = (require("Storage").readJSON("setting.json", 1) || {})["12hour"];
|
||||
|
||||
const interpolatePos = function(pos1, pos2, factor, easing) {
|
||||
if (easing !== undefined) {
|
||||
factor = Math.pow(factor, easing);
|
||||
}
|
||||
return {x: (pos1.x*(1-factor) + pos2.x*factor)/2, y: (pos1.y*(1-factor) + pos2.y*factor)/2}
|
||||
}
|
||||
|
||||
let drawSplashScreen = function (frame, total) {
|
||||
const R = Bangle.appRect;
|
||||
g.reset().setColor(g.theme.fg).setBgColor(g.theme.bg);
|
||||
const startPos = {x: -200, y: R.h/2};
|
||||
const endPos = {x: R.x2 - supaClockImg.width*2 + 30, y: R.h/2};
|
||||
const pos = interpolatePos(startPos, endPos, frame/total, 0.1)
|
||||
g.setFontAlign(0, 1).setColor('#888').setFont("4x6:3").drawString('ULTRA', 100, frame*18);
|
||||
g.setFontAlign(0, 1).setColor('#888').setFont("4x6:3").drawString('PRO', 40, R.x2 - frame*18);
|
||||
g.clearRect(0, pos.y-5, R.x2, pos.y + supaClockImg.height+25);
|
||||
var date = new Date();
|
||||
let minutes = date.getMinutes();
|
||||
minutes = (minutes < 10 ? '0' : '') + minutes;
|
||||
let hours = date.getHours()+'';
|
||||
g.drawImage(supaClockImg, pos.x, pos.y, {scale: 2});
|
||||
g.setColor(0).setFont('6x8:2').setFontAlign(0, 1).drawString(hours + ':' + minutes, R.x2/2, pos.y + supaClockImg.height + 25)
|
||||
}
|
||||
|
||||
// for fast startup-feeling, draw the splash screen once directly once
|
||||
g.clear()
|
||||
drawSplashScreen(0, 20);
|
||||
|
||||
let splashScreen = function () {
|
||||
g.clearRect(R.x,R.y, R.x2, R.y2);
|
||||
return new Promise((resolve, reject) => {
|
||||
let frame = 0;
|
||||
function tick() {
|
||||
if (removeHasNotRun) drawSplashScreen(frame, 20);
|
||||
frame += 1;
|
||||
if (!removeHasNotRun) {
|
||||
reject();
|
||||
} else if (frame < 20) {
|
||||
setTimeout(tick, 50);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
tick();
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Graphics.prototype.setFontPlayfairDisplay = function() {
|
||||
// https://www.espruino.com/Font+Converter
|
||||
// <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital@0;1&display=swap" rel="stylesheet">
|
||||
// 60pt, 2bpp, Numeric
|
||||
// Actual height 62 (67 - 6)
|
||||
return this.setFontCustom(
|
||||
E.toString(require('heatshrink').decompress(atob('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'))),
|
||||
46,
|
||||
atob("ExouGyYjJiEoISgoFQ=="),
|
||||
70|65536
|
||||
);
|
||||
}
|
||||
|
||||
Graphics.prototype.setFontPlayfairDisplaySm = function() {
|
||||
// Actual height 18 (17 - 0)
|
||||
// <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,800;1,800&display=swap" rel="stylesheet">
|
||||
// 18pt, 1bpp, ASCII capitals
|
||||
return this.setFontCustom(
|
||||
E.toString(require('heatshrink').decompress(atob('ABU/weP/3j/E4BAMIgEH4EB8EAkEAjwICgGADYcQgFEgEX4EeoEBBANHgE9gEEBAYABjl8h+Gg/woM+iFP4n///En1Bw/wvH4CgIXBgfggP4glDg0QoUH+cA/MAgO+gGf4HEiHBwlAn8Ah5NCgeAgPwh3+g/j4MQuFEzkc+cHmXA7+wg/8gO3g9hwP44Fv8ETEARbCPoMfPoIIDgf8gf/4P//nwh9gBgUEAQPwg8f//D//An6gBgEUJ4SoBgP+gF/wAqBgfwgFIZAqaBEwMBAwKjB/4IGCIStDJ4ISBEgIADmEAhhXBAwLcBBAYhCAAcBBoNwXgYWDfwPAQgIgBDI0AW4Mf8EPQwOHgGAoEgiEMhiPBOAUPEoZbCoEfSAKhCMoZEDCQPA4Eg+EMvkD+75B4EcKAtAhEQgUIoODmFA/1wn/8h8+WgIpDb4M4gEWgEJwEMuEH/+D/7EBJwLQCR4Mg8kInMGh1Dgef4Hn8F4/EAjB/Ej/Aj/4h//gfh4OQiFGhkh/8In7uB4EOYAOAGQPwnH+h1/gewgDWBZILiDgfPwP7+F/gkT8MEvlB//wvv8ghtBAAMPFwPwgf+kHBxEgkkMj6qBwF/4EPNYYAB8PAnFwhzyERgIIBjrgBQgLDDAQIeBlEAicAglAgUQgGCgFgwAFBAAkSCIOAgK3BpAILGA1AwEIkECVgNEGoUCSwUAGIYgBLQLqB8WAnGBh0xwZxBgKjBeIMAjzSBsEQgkIgGEn0in/Iz/yo0IyMOkl/5Mf+FHIAMCgZIBv5PFgfAgcQg2Ah0gg/ogP/gE//gECj6aBH4MMDYMEgDXCv/8j//gkQoICBdIIIBg/v4HzOAN4G4X+HwPAn/4CIUB4KABoAdBgIsBS4Mgvl8KYosBGoUH/4aIoPAuAsBh/+gI1BSYIABCIIaCLIZWDoM/EYUcg8HQwI6DDRsfKYNAGAMHcgLaBh/wHwMD/+B+HwsBQDhFBWYNA/kIn0H5/AgQ1LVQZNBQAdBI44LBAAYUBR4gRBDoQAChKHBv//z//4//8IdEdJdAg5wB8ETFgMP4JsBoEcHwbOLFIQRCoEAuEAdIQ1EvhZB4EH/kAv/gAgU8gEcgE4AIJrNHwsBgfggF+YoPAgP4gE/VoLFBNYYbBcAMfa4nB4FwFgLXCKAOAmF4ngRDEoOAgaaEPpMCTYOEiFgg/4gJoBnyjBeoQjCj/6FgOHw/hwE4WwI+B4kAvPAn1//eP/3h/84j6JBa5tBBYND8BHC9/A/PwjAcBYoUAuPwn0Mj/BKANBj0QofEiH/gYLB8akBkBWBg+AgOAcYIyBgbFEHwKYFeIb+D//gv/4KAUB4CACBwQCBwP/4FAgEYGoaYBv/Ai/+AgUD+EAnEAuEE8AkCDQJsBg72BCoXwJwKxB4MB8Fw4EfwEH/hHCp4vCDYMBhxZCHwLpEsEMj0Hg/DoP9iFffoP4DgMBk/wuF8jEPMQJrCsBHFRgKPBgZHDh/wrgRCDQIACvEcjEfgi8Bj/wr/kj/hg/goPgmFgVYcAE4IAEJAIlCHwMGAgNwCQLGBNQL7CgTHCAAiCBAAQA='))),
|
||||
32,
|
||||
atob("BAUHCwsNEQQGBgkKBQkFBwwHCgkKCQoJCgoFBQsLCwkQDAwNDgwLDQ8HBw0LEQ0PDA8NCwwMDBINCwsGBwY="),
|
||||
18|65536
|
||||
);
|
||||
}
|
||||
|
||||
// Actually draw the watch face
|
||||
let draw = function() {
|
||||
g.reset().setColor(g.theme.fg).setBgColor(g.theme.bg);
|
||||
g.clearRect(R.x,R.y, R.x2, R.y2 - 60);
|
||||
var date = new Date();
|
||||
let minutes = date.getMinutes();
|
||||
minutes = (minutes < 10 ? '0' : '') + minutes;
|
||||
|
||||
g.setColor(g.theme.fg)
|
||||
// Time
|
||||
const yt = R.y + 92 - 20 - 30 + 6 + 10;
|
||||
const xt = R.w/2 - 5;
|
||||
let hours = date.getHours()+'';
|
||||
g.setFontAlign(1, 0).setFontPlayfairDisplay().drawString(hours, xt - 8, yt);
|
||||
g.setFontAlign(0, 0).setFontPlayfairDisplay().drawString(':', xt, yt);
|
||||
g.setFontAlign(-1, 0).setFontPlayfairDisplay().drawString(minutes, xt + 8, yt);
|
||||
// logo
|
||||
g.drawImage(supaClockImg, R.x2 - supaClockImg.width - 2, R.y + 2);
|
||||
// dow + date
|
||||
let dateStr = require("locale").dow(date).toUpperCase() + '\n' + require("locale").month(date, 2).toUpperCase() + ' ' + date.getDate();
|
||||
g.setFont('6x8').setFontAlign(-1, 0).drawString(dateStr, R.x2 - supaClockImg.width - 2, R.y + 42 - 30 + 8);
|
||||
|
||||
if (drawTimeout) clearTimeout(drawTimeout);
|
||||
drawTimeout = setTimeout(function() {
|
||||
drawTimeout = undefined;
|
||||
draw();
|
||||
}, 60000 - (Date.now() % 60000));
|
||||
};
|
||||
|
||||
let clockInfoDraw = (itm, info, options) => {
|
||||
g.reset().setFontPlayfairDisplaySm().setColor(g.theme.fg).setBgColor(g.theme.bg);
|
||||
if (options.focus) g.setBgColor("#FF0");
|
||||
g.clearRect({x:options.x,y:options.y,w:options.w,h:options.h});
|
||||
|
||||
if (info.img) {
|
||||
g.drawImage(info.img, options.x+1,options.y+2);
|
||||
}
|
||||
var text = info.text.toString().toUpperCase();
|
||||
if (g.setFontPlayfairDisplaySm().stringWidth(text)+24-2>options.w) g.setFont("4x6:2");
|
||||
g.setFontAlign(-1,-1).drawString(text, options.x+24+3, options.y+6);
|
||||
};
|
||||
|
||||
let clockInfoDrawR = (itm, info, options) => {
|
||||
g.reset().setFontPlayfairDisplaySm().setColor(g.theme.fg).setBgColor(g.theme.bg);
|
||||
if (options.focus) g.setBgColor("#FF0");
|
||||
g.clearRect({x:options.x,y:options.y,w:options.w,h:options.h});
|
||||
|
||||
if (info.img) {
|
||||
g.drawImage(info.img, options.x + options.w-1-24,options.y+2);
|
||||
}
|
||||
var text = info.text.toString().toUpperCase();
|
||||
if (g.setFontPlayfairDisplaySm().stringWidth(text)+24-2>options.w) g.setFont("4x6:2");
|
||||
g.setFontAlign(1,-1).drawString(text, options.x+options.w-24-3, options.y+6);
|
||||
};
|
||||
|
||||
|
||||
let clockInfoItems;
|
||||
let clockInfoMenu1;
|
||||
let clockInfoMenu2;
|
||||
let clockInfoMenu3;
|
||||
let clockInfoMenu4;
|
||||
|
||||
// Show launcher when middle button pressed
|
||||
Bangle.setUI({
|
||||
mode : "clock",
|
||||
remove : function() { // for fastloading, clear the app memory
|
||||
removeHasNotRun = false;
|
||||
if (drawTimeout) clearTimeout(drawTimeout);
|
||||
drawTimeout = undefined;
|
||||
delete Graphics.prototype.setFontPlayfairDisplay
|
||||
delete Graphics.prototype.setFontPlayfairDisplaySm
|
||||
clockInfoMenu1&&clockInfoMenu1.remove();
|
||||
clockInfoMenu2&&clockInfoMenu2.remove();
|
||||
clockInfoMenu3&&clockInfoMenu3.remove();
|
||||
clockInfoMenu4&&clockInfoMenu4.remove();
|
||||
}});
|
||||
|
||||
Bangle.loadWidgets();
|
||||
|
||||
let R = Bangle.appRect;
|
||||
let midX = R.x+R.w/2;
|
||||
let upperCI = R.y2-28-28;
|
||||
let lowerCI = R.y2-28;
|
||||
|
||||
g.clearRect(R.x, R.y, R.x2, R.y2);
|
||||
splashScreen().then(() => {
|
||||
g.clearRect(R.x, 0, R.x2, R.y2);
|
||||
draw();
|
||||
Bangle.drawWidgets();
|
||||
// Allocate and draw clockinfos
|
||||
g.setFontAlign(1, 1).setFont('6x8').drawString('Loading Clock Info Modules...', R.x + 10, upperCI);
|
||||
setTimeout(() => {
|
||||
// delay loading of clock info, so that the clock face appears quicker
|
||||
g.clearRect(R.x, upperCI, R.x2, upperCI+10); // clear loading text
|
||||
try {
|
||||
clockInfoItems = require("clock_info").load();
|
||||
clockInfoMenu1 = require("clock_info").addInteractive(clockInfoItems, { app:"lcdclock", x:R.x+1, y:upperCI, w:midX-2, h:28, draw : clockInfoDraw});
|
||||
clockInfoMenu2 = require("clock_info").addInteractive(clockInfoItems, { app:"lcdclock", x:midX+1, y:upperCI, w:midX-2, h:28, draw : clockInfoDrawR});
|
||||
clockInfoMenu3 = require("clock_info").addInteractive(clockInfoItems, { app:"lcdclock", x:R.x+1, y:lowerCI, w:midX-2, h:28, draw : clockInfoDraw});
|
||||
clockInfoMenu4 = require("clock_info").addInteractive(clockInfoItems, { app:"lcdclock", x:midX+1, y:lowerCI, w:midX-2, h:28, draw : clockInfoDrawR});
|
||||
} catch(err) {
|
||||
if ((err + '').includes('Module "clock_info" not found' )) {
|
||||
g.setFont('6x8').drawString('Please install\nclockinfo module!', R.x + 10, upperCI);
|
||||
}
|
||||
}
|
||||
}, 1);
|
||||
},() => {});
|
||||
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
|
|
@ -0,0 +1,16 @@
|
|||
{ "id": "supaclk",
|
||||
"name": "SUPACLOCK Pro ULTRA",
|
||||
"version": "0.01",
|
||||
"description": "SUPACLOCK Pro ULTRA, with four ClockInfo areas at the bottom. Tap them and swipe up/down and left/right to toggle between different information.",
|
||||
"icon": "app.png",
|
||||
"screenshots": [{"url":"screenshot.png"},{"url":"screenshot2.png"}],
|
||||
"type": "clock",
|
||||
"tags": "clock,clkinfo,clockinfo",
|
||||
"supports" : ["BANGLEJS2"],
|
||||
"readme": "README.md",
|
||||
"dependencies" : { "clock_info":"module" },
|
||||
"storage": [
|
||||
{"name":"supaclk.app.js","url":"app.js"},
|
||||
{"name":"supaclk.img","url":"app-icon.js","evaluate":true}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
|
|
@ -16,7 +16,7 @@ if (window.location.host=="banglejs.com") {
|
|||
'This is not the official Bangle.js App Loader - you can try the <a href="https://banglejs.com/apps/">Official Version</a> here.';
|
||||
}
|
||||
|
||||
var RECOMMENDED_VERSION = "2v21";
|
||||
var RECOMMENDED_VERSION = "2v22";
|
||||
// could check http://www.espruino.com/json/BANGLEJS.json for this
|
||||
|
||||
// We're only interested in Bangles
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
exports.offset = 0;
|
||||
exports.hide = function() {
|
||||
exports.cleanup();
|
||||
if (!global.WIDGETS) return;
|
||||
|
|
@ -26,22 +27,12 @@ exports.show = function() {
|
|||
}
|
||||
};
|
||||
|
||||
/// Remove any intervals/handlers/etc that we might have added. Does NOT re-show widgets that were hidden
|
||||
exports.cleanup = function() {
|
||||
/// Remove anything not needed if the overlay was removed
|
||||
exports.cleanupOverlay = function() {
|
||||
exports.offset = -24;
|
||||
Bangle.setLCDOverlay(undefined, {id: "widget_utils"});
|
||||
delete exports.autohide;
|
||||
delete Bangle.appRect;
|
||||
if (exports.origSetLCDOverlay){
|
||||
Bangle.setLCDOverlay = exports.origSetLCDOverlay;
|
||||
}
|
||||
delete exports.origSetLCDOverlay;
|
||||
if (exports.cleanUpOverlay){
|
||||
Bangle.setLCDOverlay();
|
||||
}
|
||||
delete exports.cleanUpOverlay;
|
||||
if (exports.swipeHandler) {
|
||||
Bangle.removeListener("swipe", exports.swipeHandler);
|
||||
delete exports.swipeHandler;
|
||||
}
|
||||
if (exports.animInterval) {
|
||||
clearInterval(exports.animInterval);
|
||||
delete exports.animInterval;
|
||||
|
|
@ -50,6 +41,16 @@ exports.cleanup = function() {
|
|||
clearTimeout(exports.hideTimeout);
|
||||
delete exports.hideTimeout;
|
||||
}
|
||||
};
|
||||
|
||||
/// Remove any intervals/handlers/etc that we might have added. Does NOT re-show widgets that were hidden
|
||||
exports.cleanup = function() {
|
||||
exports.cleanupOverlay();
|
||||
delete exports.offset;
|
||||
if (exports.swipeHandler) {
|
||||
Bangle.removeListener("swipe", exports.swipeHandler);
|
||||
delete exports.swipeHandler;
|
||||
}
|
||||
if (exports.origDraw) {
|
||||
Bangle.drawWidgets = exports.origDraw;
|
||||
delete exports.origDraw;
|
||||
|
|
@ -74,14 +75,6 @@ exports.swipeOn = function(autohide) {
|
|||
/* TODO: maybe when widgets are offscreen we don't even
|
||||
store them in an offscreen buffer? */
|
||||
|
||||
if (!exports.origSetLCDOverlay) {
|
||||
exports.origSetLCDOverlay = Bangle.setLCDOverlay;
|
||||
Bangle.setLCDOverlay = function(){
|
||||
require("widget_utils").origSetLCDOverlay.apply(Bangle, arguments);
|
||||
require("widget_utils").cleanUpOverlay = false;
|
||||
};
|
||||
}
|
||||
|
||||
// force app rect to be fullscreen
|
||||
Bangle.appRect = { x: 0, y: 0, w: g.getWidth(), h: g.getHeight(), x2: g.getWidth()-1, y2: g.getHeight()-1 };
|
||||
// setup offscreen graphics for widgets
|
||||
|
|
@ -93,16 +86,23 @@ exports.swipeOn = function(autohide) {
|
|||
};
|
||||
og.reset().clearRect(0,0,og.getWidth(),23).fillRect(0,24,og.getWidth(),25);
|
||||
let _g = g;
|
||||
let offset = -24; // where on the screen are we? -24=hidden, 0=full visible
|
||||
exports.offset = -24; // where on the screen are we? -24=hidden, 0=full visible
|
||||
|
||||
function queueDraw() {
|
||||
Bangle.appRect.y = offset+24;
|
||||
Bangle.appRect.h = 1 + Bangle.appRect.y2 - Bangle.appRect.y;
|
||||
if (offset>-24) {
|
||||
Bangle.setLCDOverlay(og, 0, offset);
|
||||
exports.cleanUpOverlay = true;
|
||||
} else {
|
||||
Bangle.setLCDOverlay();
|
||||
const o = exports.offset;
|
||||
if (o>-24) {
|
||||
Bangle.appRect.y = o+24;
|
||||
Bangle.appRect.h = 1 + Bangle.appRect.y2 - Bangle.appRect.y;
|
||||
if (o>-24) {
|
||||
Bangle.setLCDOverlay(og, 0, o, {
|
||||
id:"widget_utils",
|
||||
remove:()=>{
|
||||
require("widget_utils").cleanupOverlay();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Bangle.setLCDOverlay(undefined, {id: "widget_utils"});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ exports.swipeOn = function(autohide) {
|
|||
g=og;
|
||||
this._draw(this);
|
||||
g=_g;
|
||||
if (offset>-24) queueDraw();
|
||||
if (exports.offset>-24) queueDraw();
|
||||
};
|
||||
w._area = w.area;
|
||||
if (w.area.startsWith("b"))
|
||||
|
|
@ -129,14 +129,14 @@ exports.swipeOn = function(autohide) {
|
|||
function anim(dir, callback) {
|
||||
if (exports.animInterval) clearInterval(exports.animInterval);
|
||||
exports.animInterval = setInterval(function() {
|
||||
offset += dir;
|
||||
exports.offset += dir;
|
||||
let stop = false;
|
||||
if (dir>0 && offset>=0) { // fully down
|
||||
if (dir>0 && exports.offset>=0) { // fully down
|
||||
stop = true;
|
||||
offset = 0;
|
||||
} else if (dir<0 && offset<-23) { // fully up
|
||||
exports.offset = 0;
|
||||
} else if (dir<0 && exports.offset<-23) { // fully up
|
||||
stop = true;
|
||||
offset = -24;
|
||||
exports.offset = -24;
|
||||
}
|
||||
if (stop) {
|
||||
clearInterval(exports.animInterval);
|
||||
|
|
@ -158,8 +158,8 @@ exports.swipeOn = function(autohide) {
|
|||
anim(-4);
|
||||
}, exports.autohide);
|
||||
};
|
||||
if (ud>0 && offset<0) anim(4, cb);
|
||||
if (ud<0 && offset>-24) anim(-4);
|
||||
if (ud>0 && exports.offset<0) anim(4, cb);
|
||||
if (ud<0 && exports.offset>-24) anim(-4);
|
||||
};
|
||||
Bangle.on("swipe", exports.swipeHandler);
|
||||
Bangle.drawWidgets();
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
"lint-apps": "node bin/sync-lint-exemptions.mjs && eslint ./apps",
|
||||
"lint-modules": "eslint ./modules",
|
||||
"test": "node bin/sanitycheck.js && npm run lint-apps && npm run lint-modules",
|
||||
"fix": "eslint --fix ./apps ./modules",
|
||||
"update-local-apps": "./bin/create_apps_json.sh apps.local.json",
|
||||
"local": "npm-watch & npx http-server -a localhost -c-1",
|
||||
"start": "npx http-server -c-1"
|
||||
|
|
|
|||
Loading…
Reference in New Issue