[gbmusic] fix lint warnings

master
Logan B 2025-02-08 16:01:18 -06:00
parent bce6a07f1b
commit 63797c402a
No known key found for this signature in database
2 changed files with 62 additions and 58 deletions

View File

@ -128,57 +128,60 @@ function rInfo(l) {
.setFontAlign(0, -1) // center top .setFontAlign(0, -1) // center top
.drawString(l.label, l.x+l.w/2, l.y); .drawString(l.label, l.x+l.w/2, l.y);
} }
/**
* Render icon // *** Unused Function ***
* @param l // // /**
*/ // // * Render icon
function rIcon(l) { // // * @param l
const x2 = l.x+l.w-1, // // */
y2 = l.y+l.h-1; // // function rIcon(l) {
switch(l.icon) { // // const x2 = l.x+l.w-1,
case "pause": { // // y2 = l.y+l.h-1;
const w13 = l.w/3; // // switch(l.icon) {
g.drawRect(l.x, l.y, l.x+w13, y2); // // case "pause": {
g.drawRect(l.x+l.w-w13, l.y, x2, y2); // // const w13 = l.w/3;
break; // // g.drawRect(l.x, l.y, l.x+w13, y2);
} // // g.drawRect(l.x+l.w-w13, l.y, x2, y2);
case "play": { // // break;
g.drawPoly([ // // }
l.x, l.y, // // case "play": {
x2, l.y+l.h/2, // // g.drawPoly([
l.x, y2, // // l.x, l.y,
], true); // // x2, l.y+l.h/2,
break; // // l.x, y2,
} // // ], true);
case "previous": { // // break;
const w15 = l.w*1/5; // // }
g.drawPoly([ // // case "previous": {
x2, l.y, // // const w15 = l.w*1/5;
l.x+w15, l.y+l.h/2, // // g.drawPoly([
x2, y2, // // x2, l.y,
], true); // // l.x+w15, l.y+l.h/2,
g.drawRect(l.x, l.y, l.x+w15, y2); // // x2, y2,
break; // // ], true);
} // // g.drawRect(l.x, l.y, l.x+w15, y2);
case "next": { // // break;
const w45 = l.w*4/5; // // }
g.drawPoly([ // // case "next": {
l.x, l.y, // // const w45 = l.w*4/5;
l.x+w45, l.y+l.h/2, // // g.drawPoly([
l.x, y2, // // l.x, l.y,
], true); // // l.x+w45, l.y+l.h/2,
g.drawRect(l.x+w45, l.y, x2, y2); // // l.x, y2,
break; // // ], true);
} // // g.drawRect(l.x+w45, l.y, x2, y2);
default: { // red X // // break;
console.log(`Unknown icon: ${l.icon}`); // // }
g.setColor("#f00") // // default: { // red X
.drawRect(l.x, l.y, x2, y2) // // console.log(`Unknown icon: ${l.icon}`);
.drawLine(l.x, l.y, x2, y2) // // g.setColor("#f00")
.drawLine(l.x, y2, x2, l.y); // // .drawRect(l.x, l.y, x2, y2)
} // // .drawLine(l.x, l.y, x2, y2)
} // // .drawLine(l.x, y2, x2, l.y);
} // // }
// // }
// // }
let layout; let layout;
function makeUI() { function makeUI() {
Bangle.loadWidgets(); Bangle.loadWidgets();
@ -489,10 +492,10 @@ function startLCDWatch() {
Bangle.on("lcdPower", (on) => { Bangle.on("lcdPower", (on) => {
if (on) { if (on) {
// redraw and resume scrolling // redraw and resume scrolling
tick(); //tick(); // Not sure what this function was; currently undefined
layout.render(); layout.render();
fadeOut(); fadeOut();
if (offset.offset!==null) { if (layout.title.offset!==null) { // Making an assumption about what offset.offset was supposed to be
if (!iScroll) { if (!iScroll) {
iScroll = setInterval(scroll, 200); iScroll = setInterval(scroll, 200);
} }

View File

@ -1,6 +1,6 @@
setTimeout( // make other boot code run first, so we override e.g. android.boot.js GB setTimeout( // make other boot code run first, so we override e.g. android.boot.js GB
() => { () => {
const APP = global.__FILE__==="gbmusic.app.js", const APP = globalThis.__FILE__==="gbmusic.app.js",
a = !!(require("Storage").readJSON("gbmusic.json", 1) || {}).autoStart; a = !!(require("Storage").readJSON("gbmusic.json", 1) || {}).autoStart;
let s, i; // state, info let s, i; // state, info
@ -20,18 +20,19 @@ setTimeout( // make other boot code run first, so we override e.g. android.boot.
load("gbmusic.app.js"); load("gbmusic.app.js");
} }
global.GB = (_GB => e => {
globalThis.GB = (_GB => e => {
// we eat music events! // we eat music events!
switch(e.t) { switch(e.t) {
case "musicinfo": case "musicinfo":
i = e; i = e;
return APP ? info(e) : check(); return APP ? globalThis.info(e) : check();
case "musicstate": case "musicstate":
s = e; s = e;
return APP ? state(e) : check(); return APP ? globalThis.state(e) : check();
default: default:
// pass on other events // pass on other events
if (_GB) setTimeout(_GB, 0, e); if (_GB) setTimeout(_GB, 0, e);
} }
})(global.GB); })(globalThis.GB);
}, 1); }, 1);