mirror of https://github.com/espruino/BangleApps
Fix apps with undefined variables
parent
6c2be207c6
commit
a468292536
|
@ -22,7 +22,7 @@
|
|||
console.log("Button let go");
|
||||
digitalWrite(LED2,0);
|
||||
var unpress_time = new Date();
|
||||
recFile = require("Storage").open("one_button_presses.csv","a");
|
||||
const recFile = require("Storage").open("one_button_presses.csv","a");
|
||||
recFile.write([press_time.getTime(),unpress_time.getTime()].join(",")+"\n");
|
||||
}, BTN1, { repeat: true, edge: 'falling', debounce: 50 });
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ function Maze(n) {
|
|||
return false;
|
||||
};
|
||||
this.tick = function() {
|
||||
accel = Bangle.getAccel();
|
||||
let accel = Bangle.getAccel();
|
||||
if (this.ball_x%this.wall_length) {
|
||||
this.try_move_horizontally(accel.x);
|
||||
} else if (this.ball_y%this.wall_length) {
|
||||
|
|
|
@ -32,10 +32,10 @@
|
|||
}
|
||||
|
||||
function storeData() {
|
||||
now = new Date();
|
||||
month = now.getMonth() + 1; //month is 0-based
|
||||
let now = new Date();
|
||||
let month = now.getMonth() + 1; //month is 0-based
|
||||
if (month < 10) month = "0" + month; //leading 0
|
||||
filename = filename = "activepedom" + now.getFullYear() + month + now.getDate() + ".data"; //new file for each day
|
||||
let filename = "activepedom" + now.getFullYear() + month + now.getDate() + ".data"; //new file for each day
|
||||
dataFile = s.open(filename,"a");
|
||||
if (dataFile) { //check if filen already exists
|
||||
if (dataFile.getLength() == 0) {
|
||||
|
@ -231,7 +231,7 @@
|
|||
stepsTooLong = pedomData.stepsTooLong;
|
||||
stepsOutsideTime = pedomData.stepsOutsideTime;
|
||||
}
|
||||
pedomdata = 0; //reset pedomdata to save memory
|
||||
pedomdata = 0; //reset pedomdata to save memory - TODO: Should `pedomdata` have been `pedomData` here?
|
||||
|
||||
setStepSensitivity(setting('stepSensitivity')); //set step sensitivity (80 is standard, 400 is muss less sensitive)
|
||||
/*timerStoreData =*/ setInterval(storeData, storeDataInterval); //store data regularly
|
||||
|
|
|
@ -107,7 +107,7 @@ let isoStr = function(date) {
|
|||
|
||||
let calWeekBuffer = [false,false,false]; //buffer tz, date, week no (once calculated until other tz or date is requested)
|
||||
let ISO8601calWeek = function(date) { //copied from: https://gist.github.com/IamSilviu/5899269#gistcomment-3035480
|
||||
dateNoTime = date; dateNoTime.setHours(0,0,0,0);
|
||||
const dateNoTime = date; dateNoTime.setHours(0,0,0,0);
|
||||
if (calWeekBuffer[0] === date.getTimezoneOffset() && calWeekBuffer[1] === dateNoTime) return calWeekBuffer[2];
|
||||
calWeekBuffer[0] = date.getTimezoneOffset();
|
||||
calWeekBuffer[1] = dateNoTime;
|
||||
|
|
|
@ -136,6 +136,7 @@ else if (img == "apetureLaboratoriesLight"){
|
|||
function drawStart(){
|
||||
g.clear();
|
||||
g.reset();
|
||||
let apSciLab;
|
||||
if (g.theme.dark){apSciLab = getImg("apetureLaboratories");}
|
||||
else {apSciLab = getImg("apetureLaboratoriesLight");}
|
||||
g.drawImage(apSciLab, xyCenter-apSciLab.width/2, xyCenter-apSciLab.height/2);
|
||||
|
@ -241,7 +242,7 @@ function buttonPressed(){
|
|||
if (curWarning < maxWarning) curWarning += 1;
|
||||
else curWarning = 0;
|
||||
g.reset();
|
||||
buttonImg = getImg("butPress");
|
||||
const buttonImg = getImg("butPress");
|
||||
g.drawImage(buttonImg, 0, 0);
|
||||
|
||||
warningImg = getImg("w"+String(curWarning));
|
||||
|
@ -251,7 +252,7 @@ function buttonPressed(){
|
|||
}
|
||||
function buttonUnpressed(){
|
||||
if (!pause){
|
||||
buttonImg = getImg("butUnpress");
|
||||
const buttonImg = getImg("butUnpress");
|
||||
g.drawImage(buttonImg, 0, 0);
|
||||
}
|
||||
else{
|
||||
|
@ -277,11 +278,12 @@ function draw() {
|
|||
|
||||
g.reset(); // default draw styles
|
||||
//draw watchface
|
||||
let apSciWatch;
|
||||
if (g.theme.dark){apSciWatch = getImg("apetureWatch");}
|
||||
else {apSciWatch = getImg("apetureWatchLight");}
|
||||
g.drawImage(apSciWatch, xyCenter-apSciWatch.width/2, xyCenter-apSciWatch.height/2);
|
||||
|
||||
potato = getImg("potato");
|
||||
const potato = getImg("potato");
|
||||
g.drawImage(potato, 118, 118);
|
||||
|
||||
g.drawImage(warningImg, 1, g.getWidth()-61);//update warning
|
||||
|
|
|
@ -23,7 +23,7 @@ function drawMoon(phase, x, y) {
|
|||
"waning-crescent",
|
||||
];
|
||||
|
||||
img = require("Storage").read(`${moonImgFiles[phase]}.img`);
|
||||
const img = require("Storage").read(`${moonImgFiles[phase]}.img`);
|
||||
// image width & height = 92px
|
||||
g.drawImage(img, x - parseInt(92 / 2), y);
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ function draw() {
|
|||
g.drawString(""+bt_current_humi, 123, 110);
|
||||
g.drawString(""+bt_current_temp, 158, 110);
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
for (let i = 0; i < 10; i++) {
|
||||
if (display_frozen) { g.setColor("#888"); }
|
||||
|
||||
// max height = 32
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
BANGLEJS2 = process.env.HWVERSION==2;
|
||||
const BANGLEJS2 = process.env.HWVERSION==2;
|
||||
Bangle.setLCDBrightness(1);
|
||||
if (!BANGLEJS2) Bangle.setLCDMode("doublebuffered");
|
||||
Bangle.setLCDTimeout(0);
|
||||
|
|
|
@ -148,7 +148,7 @@ function accelHandler(accel) {
|
|||
|
||||
// slope for Z
|
||||
if (exerciseType.useZaxis) {
|
||||
l = historyAvgZ.length;
|
||||
let l = historyAvgZ.length;
|
||||
if (l > 1) {
|
||||
const p1 = historyAvgZ[l - 2];
|
||||
const p2 = historyAvgZ[l - 1];
|
||||
|
|
|
@ -101,6 +101,7 @@ function loadLinesFromFile(requestedLineCount, fileName) {
|
|||
|
||||
var readFile = Storage.open(fileName, "r");
|
||||
|
||||
let nextLine;
|
||||
while ((nextLine = readFile.readLine())) {
|
||||
if(nextLine) {
|
||||
allLines.push(nextLine);
|
||||
|
|
|
@ -31,7 +31,7 @@ function draw() {
|
|||
var dow = require("date_utils").dows(0,1)[date.getDay()];
|
||||
|
||||
if ((date.getTime() >= lastBattCheck + 15*60000) || Bangle.isCharging()) {
|
||||
lastBattcheck = date.getTime();
|
||||
lastBattcheck = date.getTime(); // TODO: should `lastBattcheck` have been `lastBattCheck` ?
|
||||
width = E.getBattery();
|
||||
width += width/2;
|
||||
}
|
||||
|
|
|
@ -409,7 +409,7 @@ function updateClock() {
|
|||
|
||||
if ( emulator ) {
|
||||
max.spd++; max.alt++;
|
||||
d=new Date(); sec=d.getSeconds();
|
||||
const d=new Date(); sec=d.getSeconds();
|
||||
onGPS(lf);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ var cgimg;
|
|||
*/
|
||||
function drawSquare(gfx, x, y, data, numOfBits) {
|
||||
|
||||
for(i = numOfBits; i > 0 ; i--) {
|
||||
for(let i = numOfBits; i > 0 ; i--) {
|
||||
if( (data & 1) != 0) {
|
||||
gfx.fillRect(x + (i - 1) * x_step, y,
|
||||
x + i * x_step , y + y_step);
|
||||
|
@ -245,7 +245,7 @@ function drawBattery(gfx, level) {
|
|||
var pos_y = bat_pos_y - 1;
|
||||
var stepLevel = Math.round((level + 10) / 20);
|
||||
|
||||
for(i = 0; i < stepLevel; i++) {
|
||||
for(let i = 0; i < stepLevel; i++) {
|
||||
pos_y -= bat_size_y + 2;
|
||||
gfx.fillRect(bat_pos_x, pos_y,
|
||||
bat_pos_x + bat_size_x, pos_y + bat_size_y);
|
||||
|
|
|
@ -34,10 +34,10 @@ const background = {
|
|||
),
|
||||
};
|
||||
|
||||
numbersDims = {
|
||||
/*const numbersDims = {
|
||||
width: 20,
|
||||
height: 44,
|
||||
};
|
||||
};*/
|
||||
const numbers = [
|
||||
require("heatshrink").decompress(
|
||||
atob(
|
||||
|
@ -88,7 +88,7 @@ const numbers = [
|
|||
)
|
||||
),
|
||||
];
|
||||
digitPositions = [
|
||||
const digitPositions = [
|
||||
// relative to the box
|
||||
{ x: 13, y: 6 },
|
||||
{ x: 32, y: 6 },
|
||||
|
|
|
@ -51,9 +51,9 @@ g.setFont("6x8", 2);
|
|||
function circle() {
|
||||
|
||||
g.clear();
|
||||
adjusted_radius = max_radius * Math.abs(origin);
|
||||
const adjusted_radius = max_radius * Math.abs(origin);
|
||||
g.drawCircle(120, 120, adjusted_radius);
|
||||
radius = Math.abs(Math.sin(origin));
|
||||
//const radius = Math.abs(Math.sin(origin));
|
||||
angle += 2;
|
||||
origin = angle * (Math.PI / 180);
|
||||
if (angle >= 0 && angle < 90) {
|
||||
|
|
|
@ -6,7 +6,7 @@ exports.enable = () => {
|
|||
|
||||
var log = function(text, param){
|
||||
if (global.showStatusInfo)
|
||||
showStatusInfo(text);
|
||||
global.showStatusInfo(text);
|
||||
if (settings.debuglog){
|
||||
var logline = new Date().toISOString() + " - " + text;
|
||||
if (param) logline += ": " + JSON.stringify(param);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
name : "BT HR",
|
||||
fields : ["BT Heartrate", "BT Battery", "Energy expended", "Contact", "RR"],
|
||||
getValues : () => {
|
||||
result = [bpm,bat,energy,contact,rr];
|
||||
const result = [bpm,bat,energy,contact,rr];
|
||||
bpm = "";
|
||||
rr = "";
|
||||
bat = "";
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
result = [hrv];
|
||||
const result = [hrv];
|
||||
hrv = "";
|
||||
rrHistory = [];
|
||||
return result;
|
||||
|
|
|
@ -129,7 +129,7 @@ class BanglejsApp {
|
|||
|
||||
E.srand(Date.now());
|
||||
|
||||
calibration = new BanglejsApp();
|
||||
const calibration = new BanglejsApp();
|
||||
calibration.load_settings();
|
||||
Bangle.disableCalibration = true;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ if (this.imports !== undefined &&
|
|||
this.printerr !== undefined){//seed or gjs
|
||||
p4_log = function(){
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
printerr(args.join(', '));
|
||||
this.printerr(args.join(', '));
|
||||
};
|
||||
}
|
||||
else if (this.console === undefined){//MSIE
|
||||
|
|
|
@ -19,7 +19,7 @@ function drawPlayers() {
|
|||
g.clear(1);
|
||||
g.setFont("6x8",2);
|
||||
var l = [{name:ME,cnt:mycounter}];
|
||||
for (p of players) l.push(p);
|
||||
for (const p of players) l.push(p);
|
||||
l.sort((a,b)=>a.cnt-b.cnt);
|
||||
var y=0;
|
||||
l.forEach(player=>{
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
let day = true;
|
||||
let d = date.getTime();
|
||||
let dayLength = sunset.getTime()-sunrise.getTime();
|
||||
let timePast;
|
||||
let timeTotal;
|
||||
if (d < sunrise.getTime()) {
|
||||
day = false; // early morning
|
||||
|
|
|
@ -66,7 +66,7 @@ function showNumpad(text, key_, callback) {
|
|||
s = key + text.substr(key.length, 999);
|
||||
g.setFont("Vector:24").setFontAlign(1,0).drawString(s,g.getWidth(),12);
|
||||
}
|
||||
ds="12%";
|
||||
const ds="12%";
|
||||
var numPad = new Layout ({
|
||||
type:"v", c: [{
|
||||
type:"v", c: [
|
||||
|
|
|
@ -65,7 +65,7 @@ function chronometer() {
|
|||
}
|
||||
|
||||
currentLap = calculateLap(state.whenStarted);
|
||||
total = calculateLap(state.whenStartedTotal);
|
||||
const total = calculateLap(state.whenStartedTotal);
|
||||
|
||||
state.laps[0] = total;
|
||||
state.laps[1] = currentLap;
|
||||
|
|
|
@ -513,11 +513,12 @@ function encodeAcceleration() {
|
|||
function updateSensorData() {
|
||||
|
||||
// Update the battery measurement each time the cyclic count resets
|
||||
let encodedBattery;
|
||||
if(cyclicCount === 0) {
|
||||
encodedBattery = encodeBatteryPercentage();
|
||||
}
|
||||
|
||||
encodedAcceleration = encodeAcceleration();
|
||||
let encodedAcceleration = encodeAcceleration();
|
||||
|
||||
sensorData[0] = ((encodedAcceleration.x << 2) & 0xfc) |
|
||||
((encodedAcceleration.y >> 4) & 0x3f);
|
||||
|
|
|
@ -118,8 +118,8 @@ function checkHR() {
|
|||
|
||||
if(HR_samples.length == 5){
|
||||
g.clear();
|
||||
average_HR = average(HR_samples).toFixed(0);
|
||||
stdev_HR = getStandardDeviation (HR_samples).toFixed(1);
|
||||
let average_HR = average(HR_samples).toFixed(0);
|
||||
let stdev_HR = getStandardDeviation (HR_samples).toFixed(1);
|
||||
|
||||
if (ISBANGLEJS1) {
|
||||
g.drawString("HR: " + average_HR, 120,100);
|
||||
|
|
|
@ -7,7 +7,7 @@ var R = Bangle.appRect;
|
|||
var termg = Graphics.createArrayBuffer(R.w, R.h, 1, {msb:true});
|
||||
var termVisible = false;
|
||||
termg.setFont("6x8");
|
||||
term = require("VT100").connect(termg, {
|
||||
let term = require("VT100").connect(termg, {
|
||||
charWidth : 6,
|
||||
charHeight : 8
|
||||
});
|
||||
|
|
|
@ -86,7 +86,7 @@ const drawSec = function (sections, color) {
|
|||
|
||||
const drawClock = function () {
|
||||
|
||||
currentTime = new Date();
|
||||
const currentTime = new Date();
|
||||
|
||||
//Get date as a string
|
||||
date = dateStr(currentTime);
|
||||
|
@ -163,11 +163,11 @@ const drawHR = function () {
|
|||
}
|
||||
|
||||
if (grow) {
|
||||
color = settings.hr.color;
|
||||
const color = settings.hr.color;
|
||||
g.setColor(color);
|
||||
g.fillCircle(settings.hr.x, settings.hr.y, size);
|
||||
} else {
|
||||
color = "#000000";
|
||||
const color = "#000000";
|
||||
g.setColor(color);
|
||||
g.drawCircle(settings.hr.x, settings.hr.y, size);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
while (str.length > maxLength) {
|
||||
let found = false;
|
||||
// Inserts new line at first whitespace of the line
|
||||
for (i = maxLength - 1; i > 0; i--) {
|
||||
for (let i = maxLength - 1; i > 0; i--) {
|
||||
if (str.charAt(i)==' ') {
|
||||
res = res + [str.slice(0, i), "\n"].join('');
|
||||
str = str.slice(i + 1);
|
||||
|
|
|
@ -193,7 +193,7 @@ let intervalId;
|
|||
|
||||
if (BTN.read()) {
|
||||
for (let i = 0; i < 10; i++) {
|
||||
color = getColor(i);
|
||||
const color = getColor(i);
|
||||
g.setColor(color[0], color[1], color[2]);
|
||||
g.fillRect((i / 10) * h, 0, ((i + 1) / 10) * h, h);
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
"Bangle.loadWidgets()"; // Facilitates fastloading to this app via Fastload Utils, while still not loading widgets on standard `load` calls.
|
||||
|
||||
st = require('Storage');
|
||||
const st = require('Storage');
|
||||
|
||||
l = /^a\..*\.js$/;
|
||||
let l = /^a\..*\.js$/;
|
||||
//l = /.*\.js/;
|
||||
l = st.list(l, {sf:false});
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-env node */
|
||||
let fs = require('fs');
|
||||
let csv = require('csv');
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ function rotateVec(a, theta) {
|
|||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
c = Math.cos(theta);
|
||||
s = Math.sin(theta);
|
||||
const c = Math.cos(theta);
|
||||
const s = Math.sin(theta);
|
||||
pt.x = c * a.x - s * a.y;
|
||||
pt.y = s * a.x + c * a.y;
|
||||
return pt;
|
||||
|
@ -124,7 +124,7 @@ function drawHole(l) {
|
|||
nodelist.push(node.x);
|
||||
nodelist.push(node.y);
|
||||
});
|
||||
newnodelist = g.transformVertices(nodelist, transform);
|
||||
const newnodelist = g.transformVertices(nodelist, transform);
|
||||
|
||||
g.fillPoly(newnodelist, true);
|
||||
//console.log(feature.type);
|
||||
|
@ -139,7 +139,7 @@ function drawHole(l) {
|
|||
waynodelist.push(node.y);
|
||||
});
|
||||
|
||||
newnodelist = g.transformVertices(waynodelist, transform);
|
||||
const newnodelist = g.transformVertices(waynodelist, transform);
|
||||
g.setColor(0, 1, 1); // cyan
|
||||
g.drawPoly(newnodelist);
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ function rotateVec(a, theta) {
|
|||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
c = Math.cos(theta);
|
||||
s = Math.sin(theta);
|
||||
const c = Math.cos(theta);
|
||||
const s = Math.sin(theta);
|
||||
pt.x = c * a.x - s * a.y;
|
||||
pt.y = s * a.x + c * a.y;
|
||||
return pt;
|
||||
|
|
|
@ -157,7 +157,7 @@ function stopdraw() {
|
|||
|
||||
function startTimers() {
|
||||
candraw=true;
|
||||
intervalRefSec = setInterval(function() {
|
||||
/*intervalRefSec =*/ setInterval(function() {
|
||||
heading = newHeading(course,heading);
|
||||
if (course!=heading) drawCompass(heading);
|
||||
},200);
|
||||
|
|
|
@ -5,7 +5,7 @@ function bearing(a,c){var b=radians(c.lon-a.lon),d=radians(a.lat),e=radians(c.la
|
|||
function drawN(){var a=loc.speed(speed);buf.setColor(1);buf.setFont("6x8",2);buf.drawString("o",100,0);buf.setFont("6x8",1);buf.drawString(a.substring(a.length-3),220,40);buf.setFont("Vector",48);var c=course.toString();c=10>course?"00"+c:100>course?"0"+c:c;buf.drawString(c,10,0);buf.drawString(a.substring(0,a.length-3),140,4);flip(buf,Yoff+70);buf.setColor(1);buf.setFont("Vector",24);a=brg.toString();a=10>brg?"00"+a:100>brg?"0"+a:a;buf.setColor(3);buf.drawString("Brg: ",0,0);buf.drawString("Dist: ",
|
||||
0,30);buf.setColor(selected?1:2);buf.drawString(wp.name,140,0);buf.setColor(1);buf.drawString(a,60,0);buf.drawString(loc.distance(dist),60,30);flip(buf,Yoff+130);g.setFont("6x8",1);g.setColor(0,0,0);g.fillRect(10,230,60,239);g.setColor(1,1,1);g.drawString("Sats "+satellites.toString(),10,230)}var savedfix;
|
||||
function onGPS(a){savedfix=a;void 0!==a&&(course=isNaN(a.course)?course:Math.round(a.course),speed=isNaN(a.speed)?speed:a.speed,satellites=a.satellites);candraw&&(void 0!==a&&1==a.fix&&(dist=distance(a,wp),isNaN(dist)&&(dist=0),brg=bearing(a,wp),isNaN(brg)&&(brg=0)),drawN())}var intervalRef;function stopdraw(){candraw=!1;intervalRef&&clearInterval(intervalRef)}
|
||||
function startTimers(){candraw=!0;intervalRefSec=setInterval(function(){heading=newHeading(course,heading);course!=heading&&drawCompass(heading)},200)}function drawAll(){g.setColor(1,.5,.5);g.fillPoly([120,Yoff+50,110,Yoff+70,130,Yoff+70]);g.setColor(1,1,1);drawN();drawCompass(heading)}function startdraw(){g.clear();Bangle.drawWidgets();startTimers();drawAll()}
|
||||
function startTimers(){candraw=!0;setInterval(function(){heading=newHeading(course,heading);course!=heading&&drawCompass(heading)},200)}function drawAll(){g.setColor(1,.5,.5);g.fillPoly([120,Yoff+50,110,Yoff+70,130,Yoff+70]);g.setColor(1,1,1);drawN();drawCompass(heading)}function startdraw(){g.clear();Bangle.drawWidgets();startTimers();drawAll()}
|
||||
function setButtons(){setWatch(nextwp.bind(null,-1),BTN1,{repeat:!0,edge:"falling"});setWatch(doselect,BTN2,{repeat:!0,edge:"falling"});setWatch(nextwp.bind(null,1),BTN3,{repeat:!0,edge:"falling"})}var SCREENACCESS={withApp:!0,request:function(){this.withApp=!1;stopdraw();clearWatch()},release:function(){this.withApp=!0;startdraw();setButtons()}};Bangle.on("lcdPower",function(a){SCREENACCESS.withApp&&(a?startdraw():stopdraw())});var waypoints=require("waypoints").load();
|
||||
wp=waypoints[0];function nextwp(a){selected&&(wpindex+=a,wpindex>=waypoints.length&&(wpindex=0),0>wpindex&&(wpindex=waypoints.length-1),wp=waypoints[wpindex],drawN())}function doselect(){selected&&0!=wpindex&&void 0===waypoints[wpindex].lat&&savedfix.fix&&(waypoints[wpindex]={name:"@"+wp.name,lat:savedfix.lat,lon:savedfix.lon},wp=waypoints[wpindex],require("waypoints").save(waypoints));selected=!selected;drawN()}g.clear();Bangle.setLCDBrightness(1);Bangle.loadWidgets();Bangle.drawWidgets();
|
||||
Bangle.setGPSPower(1);drawAll();startTimers();Bangle.on("GPS",onGPS);setButtons();
|
||||
|
|
|
@ -168,7 +168,7 @@ function stopdraw() {
|
|||
|
||||
function startTimers() {
|
||||
candraw = true;
|
||||
intervalRefSec = setInterval(function() {
|
||||
/*intervalRefSec =*/ setInterval(function() {
|
||||
heading = newHeading(course, heading);
|
||||
if (course != heading) drawCompass(heading);
|
||||
}, 200);
|
||||
|
|
|
@ -21,7 +21,7 @@ function drawTime() {
|
|||
Bangle.buzz();
|
||||
return;
|
||||
}
|
||||
min = seconds / secsinmin;
|
||||
const min = seconds / secsinmin;
|
||||
if (seconds < quickfixperiod) {
|
||||
g.setFont('Vector', 20);
|
||||
g.drawString('Quick Fix', 125, 50);
|
||||
|
|
|
@ -116,7 +116,7 @@ function drawChordCached(chord, x, y, options) {
|
|||
if (chordCache[chord[0]]) {
|
||||
image = chordCache[chord[0]]
|
||||
} else {
|
||||
arrbuff = Graphics.createArrayBuffer(chordWidth,chordHeight,1,{msb:true});
|
||||
let arrbuff = Graphics.createArrayBuffer(chordWidth,chordHeight,1,{msb:true});
|
||||
drawChord(arrbuff, chord, 0, 0, options);
|
||||
image = {width: arrbuff.getWidth(), height: arrbuff.getHeight(), bpp:arrbuff.getBPP(), buffer: arrbuff.buffer, transparent:0}
|
||||
chordCache[chord[0]] = image;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* configured and send a trigger to homeassistant.
|
||||
*/
|
||||
function _getIcon(trigger){
|
||||
icon = trigger.icon;
|
||||
const icon = trigger.icon;
|
||||
if(icon == "light"){
|
||||
return {
|
||||
width : 48, height : 48, bpp : 1,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
latLonToGridSquare=function(o,a){var t,e,n,s,l,i,r,h,M,f=-100,g=0,u="ABCDEFGHIJKLMNOPQRSTUVWX",d=u.toLowerCase();function N(o){return"number"==typeof o?o:"string"==typeof o?parseFloat(o):"function"==typeof o?parseFloat(o()):void E.showMessage("can't convert \ninput: "+o)}return"object"==typeof o?2===o.length?(f=N(o[0]),g=N(o[1])):"lat"in o&&"lon"in o?(f=N(o.lat),g=N(o.lon)):"latitude"in o&&"longitude"in o?(f=N(o.latitude),g=N(o.longitude)):E.showMessage("can't convert \nobject "+o):(f=N(o),g=N(a)),isNaN(f)&&E.showMessage("lat is NaN"),isNaN(g)&&E.showMessage("lon is NaN"),90===Math.abs(f)&&E.showMessage("grid invalid \nat N/S"),90<Math.abs(f)&&E.showMessage("invalid lat: \n"+f),180<Math.abs(g)&&E.showMessage("invalid lon: \n"+g),t=f+90,e=g+180,n=u[Math.floor(t/10)],s=u[Math.floor(e/20)],l=""+Math.floor(t%10),i=""+Math.floor(e/2%10),h=60*(t-Math.floor(t)),M=60*(e-2*Math.floor(e/2)),r=d[Math.floor(h/2.5)],s+n+i+l+d[Math.floor(M/5)]+r};
|
||||
const latLonToGridSquare=function(o,a){var t,e,n,s,l,i,r,h,M,f=-100,g=0,u="ABCDEFGHIJKLMNOPQRSTUVWX",d=u.toLowerCase();function N(o){return"number"==typeof o?o:"string"==typeof o?parseFloat(o):"function"==typeof o?parseFloat(o()):void E.showMessage("can't convert \ninput: "+o)}return"object"==typeof o?2===o.length?(f=N(o[0]),g=N(o[1])):"lat"in o&&"lon"in o?(f=N(o.lat),g=N(o.lon)):"latitude"in o&&"longitude"in o?(f=N(o.latitude),g=N(o.longitude)):E.showMessage("can't convert \nobject "+o):(f=N(o),g=N(a)),isNaN(f)&&E.showMessage("lat is NaN"),isNaN(g)&&E.showMessage("lon is NaN"),90===Math.abs(f)&&E.showMessage("grid invalid \nat N/S"),90<Math.abs(f)&&E.showMessage("invalid lat: \n"+f),180<Math.abs(g)&&E.showMessage("invalid lon: \n"+g),t=f+90,e=g+180,n=u[Math.floor(t/10)],s=u[Math.floor(e/20)],l=""+Math.floor(t%10),i=""+Math.floor(e/2%10),h=60*(t-Math.floor(t)),M=60*(e-2*Math.floor(e/2)),r=d[Math.floor(h/2.5)],s+n+i+l+d[Math.floor(M/5)]+r};
|
||||
|
||||
Bangle.setGPSPower(1);
|
||||
var fix;
|
||||
|
|
|
@ -28,7 +28,7 @@ function showMainMenu() {
|
|||
'New Alarm': ()=>editAlarm(-1)
|
||||
};
|
||||
alarms.forEach((alarm,idx)=>{
|
||||
txt = (alarm.on?"on ":"off ")+formatTime(alarm.hr);
|
||||
let txt = (alarm.on?"on ":"off ")+formatTime(alarm.hr);
|
||||
if (alarm.rp) txt += " (repeat)";
|
||||
menu[txt] = function() {
|
||||
editAlarm(idx);
|
||||
|
|
|
@ -147,7 +147,7 @@ function drawDigits(x, value)
|
|||
function drawChar(i, xMin, yMin, xMax, yMax)
|
||||
{
|
||||
numbers[i].forEach(rect => {
|
||||
r = place(rect, xMin, yMin, xMax, yMax);
|
||||
const r = place(rect, xMin, yMin, xMax, yMax);
|
||||
g.setColor(fg,fg,fg);
|
||||
g.fillRect(r[0], r[1], r[2], r[3]);
|
||||
});
|
||||
|
|
|
@ -214,7 +214,7 @@ function graphRecord(n) {
|
|||
var measure;
|
||||
|
||||
while (line !== undefined) {
|
||||
currentLine = line;
|
||||
const currentLine = line;
|
||||
line = f.readLine();
|
||||
tempCount++;
|
||||
if (tempCount == startLine) {
|
||||
|
@ -259,7 +259,7 @@ function graphRecord(n) {
|
|||
positionX++;
|
||||
if (parseInt(currentLine.split(",")[2]) >= 70) {
|
||||
g.setColor(1, 0.3, 0.3);
|
||||
oldPositionY = positionY;
|
||||
const oldPositionY = positionY;
|
||||
measure = parseInt(currentLine.split(",")[1]);
|
||||
positionY = GraphYZero - measure + MinMeasurement;
|
||||
if (positionY > GraphYZero) {
|
||||
|
|
|
@ -71,8 +71,8 @@ function show(chars,callback) {
|
|||
return;
|
||||
}
|
||||
var m = chars.length/2;
|
||||
charl=chars.slice(0,m);
|
||||
charr=chars.slice(m);
|
||||
let charl=chars.slice(0,m);
|
||||
let charr=chars.slice(m);
|
||||
showChars(0,charl);
|
||||
showChars(120,charr);
|
||||
setWatch(() => {
|
||||
|
|
|
@ -135,7 +135,7 @@ function checkPreciseHomework(subjectnum) { // P A I N
|
|||
checkPreciseHomeworkMenu[subject] = function() {},
|
||||
checkPreciseHomeworkMenu[taskmsg] = function() {},
|
||||
checkPreciseHomeworkMenu[statusmsg] = function() {
|
||||
status = "Status: Finished";
|
||||
status = "Status: Finished"; // TODO: Should this have been called `statusmsg`?
|
||||
var d = new Date();
|
||||
var currenttime = require("locale").time(d, 1);
|
||||
var currentdate = require("locale").date(d);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
const SETTINGSFILE = "hworldclock.json";
|
||||
let secondsMode;
|
||||
let showSunInfo;
|
||||
let singleOffsetSmall;
|
||||
let colorWhenDark;
|
||||
let rotationTarget;
|
||||
// ------- Settings file
|
||||
|
@ -155,7 +156,7 @@ let updatePos = function() {
|
|||
let coord = require("Storage").readJSON(LOCATION_FILE,1)|| {"lat":0,"lon":0,"location":"-"}; //{"lat":53.3,"lon":10.1,"location":"Pattensen"};
|
||||
if (coord.lat != 0 && coord.lon != 0) {
|
||||
//pos = SunCalc.getPosition(Date.now(), coord.lat, coord.lon);
|
||||
times = SunCalc.getTimes(Date.now(), coord.lat, coord.lon);
|
||||
const times = SunCalc.getTimes(Date.now(), coord.lat, coord.lon);
|
||||
rise = "^" + times.sunrise.toString().split(" ")[4].substr(0,5);
|
||||
set = "v" + times.sunset.toString().split(" ")[4].substr(0,5);
|
||||
//noonpos = SunCalc.getPosition(times.solarNoon, coord.lat, coord.lon);
|
||||
|
@ -253,7 +254,7 @@ let draw = function() {
|
|||
|
||||
// Loop through offset(s) and render
|
||||
offsets.forEach((offset, index) => {
|
||||
dx = getCurrentTimeFromOffset(gmt, offset[OFFSET_HOURS]);
|
||||
const dx = getCurrentTimeFromOffset(gmt, offset[OFFSET_HOURS]);
|
||||
hours = doublenum(dx.getHours());
|
||||
minutes = doublenum(dx.getMinutes());
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
// Icons from https://fonts.google.com/icons
|
||||
|
||||
/* eslint-env node */
|
||||
|
||||
var imageconverter = require("../../../webtools/imageconverter.js").imageconverter;
|
||||
var icons = JSON.parse(require("fs").readFileSync(__dirname+"/icon_names.json"));
|
||||
const imgOptions = {
|
||||
|
|
|
@ -109,7 +109,7 @@ function isDictionary(object) {
|
|||
function merge(overlay, base) {
|
||||
let result = base;
|
||||
|
||||
for (objectKey in overlay) {
|
||||
for (const objectKey in overlay) {
|
||||
if (!Object.keys(base).includes(objectKey)) result[objectKey] = overlay[objectKey]; // If the key isn't there, add it
|
||||
else if (isDictionary(base[objectKey]) && isDictionary(overlay[objectKey])) // If the key is a dictionary in both, do recursive call
|
||||
result[objectKey] = merge(overlay[objectKey], base[objectKey]);
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
}
|
||||
|
||||
velocity = E.clip(velocity,-MAX_VELOCITY,MAX_VELOCITY);
|
||||
lastDrag=Date.now();
|
||||
//lastDrag=Date.now();
|
||||
if (!scheduledDraw){
|
||||
scheduledDraw = setTimeout(draw,0);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(function(){E.showScroller=function(c){function k(a){return a*c.h+b.y-l}function h(a){return Math.floor((a+l-b.y)/c.h)}if(!c)return Bangle.setUI();let p,e=0,m=0,w=setInterval(()=>{e*=.9},50),q=0,b=Bangle.appRect,n=0|c.scrollMin,r=c.h*c.c-b.h;r<n&&(r=n);const t=()=>{g.reset().clearRect(b).setClipRect(b.x,b.y,b.x2,b.y2);for(var a=h(b.y),d=Math.min(h(b.y2),c.c-1);a<=d;a++)c.draw(a,{x:b.x,y:k(a),w:b.w,h:c.h});g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1)},u=()=>{var a=e;f.scroll-a>r&&
|
||||
(a=f.scroll-r,e=0);f.scroll-a<n&&(a=f.scroll-n,e=0);f.scroll-=a;a=l;l=f.scroll&-2;a-=l;p=.01<Math.abs(e)?setTimeout(u,0):void 0;if(a){g.reset().setClipRect(b.x,b.y,b.x2,b.y2).scroll(0,a);if(0>a){a=Math.max(b.y2-(1-a),b.y);g.setClipRect(b.x,a,b.x2,b.y2);var d=h(a);for(a=k(d);a<b.y2;a+=c.h)c.draw(d,{x:b.x,y:a,w:b.w,h:c.h}),d++}else for(a=Math.min(b.y+a,b.y2),g.setClipRect(b.x,b.y,b.x2,a),d=h(a),k(d),a=k(d);a>b.y-c.h;a-=c.h)c.draw(d,{x:b.x,y:a,w:b.w,h:c.h}),d--;g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-
|
||||
1)}};let v={mode:"custom",back:c.back,drag:a=>{if(0>e&&0<a.dy||0<e&&0>a.dy)e*=-1,m=5*e;0<a.b&&(q||(q=Date.now(),m=e=0),m+=a.dy);e=m/(Date.now()-q)*100;q&&0==a.b&&(q=m=0);e=E.clip(e,-100,100);lastDrag=Date.now();p||(p=setTimeout(u,0))},touch:(a,d)=>{if(!(d.y<b.y-4)&&(m=e=0,a=h(d.y),(0>n||0<=a)&&a<c.c)){let x=d.y+l-b.y-a*c.h;print("selected");c.select(a,{x:d.x,y:x})}},redraw:t};c.remove&&(v.remove=()=>{p&&clearTimeout(p);clearInterval(w);c.remove()});Bangle.setUI(v);let f={scroll:E.clip(0|c.scroll,
|
||||
1)}};let v={mode:"custom",back:c.back,drag:a=>{if(0>e&&0<a.dy||0<e&&0>a.dy)e*=-1,m=5*e;0<a.b&&(q||(q=Date.now(),m=e=0),m+=a.dy);e=m/(Date.now()-q)*100;q&&0==a.b&&(q=m=0);e=E.clip(e,-100,100);p||(p=setTimeout(u,0))},touch:(a,d)=>{if(!(d.y<b.y-4)&&(m=e=0,a=h(d.y),(0>n||0<=a)&&a<c.c)){let x=d.y+l-b.y-a*c.h;print("selected");c.select(a,{x:d.x,y:x})}},redraw:t};c.remove&&(v.remove=()=>{p&&clearTimeout(p);clearInterval(w);c.remove()});Bangle.setUI(v);let f={scroll:E.clip(0|c.scroll,
|
||||
n,r),draw:()=>{g.reset().clearRect(b).setClipRect(b.x,b.y,b.x2,b.y2);var a=h(b.y);let d=Math.min(h(b.y2),c.c-1);for(;a<=d;a++)c.draw(a,{x:b.x,y:k(a),w:b.w,h:c.h});g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1)},drawItem:a=>{let d=k(a);g.reset().setClipRect(b.x,Math.max(d,b.y),b.x2,Math.min(d+c.h,b.y2));c.draw(a,{x:b.x,y:d,w:b.w,h:c.h});g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1)},isActive:()=>Bangle.uiRedraw==t},l=f.scroll&-2;f.draw();g.flip();return f}})()
|
|
@ -4,6 +4,8 @@ function draw() {
|
|||
g.reset();
|
||||
g.setFontCustom(font, 48, 8, 1801);
|
||||
g.setFontAlign(0, -1, 0);
|
||||
let line1;
|
||||
let line2;
|
||||
if (showDate) {
|
||||
if (g.theme.dark) {
|
||||
g.setColor("#00ffff"); // cyan date numbers for dark mode
|
||||
|
|
|
@ -36,9 +36,9 @@ function draw() {
|
|||
g.drawString(hh, 52, 65, true);
|
||||
g.drawString(mm, 132, 65, true);
|
||||
g.drawString(':', 93,65);
|
||||
dd = ("0"+(new Date()).getDate()).substr(-2);
|
||||
mo = ("0"+((new Date()).getMonth()+1)).substr(-2);
|
||||
yy = ("0"+((new Date()).getFullYear())).substr(-2);
|
||||
const dd = ("0"+(new Date()).getDate()).substr(-2);
|
||||
const mo = ("0"+((new Date()).getMonth()+1)).substr(-2);
|
||||
const yy = ("0"+((new Date()).getFullYear())).substr(-2);
|
||||
g.setFontCustom(font, 48, 8, 521);
|
||||
g.drawString(dd + ':' + mo + ':' + yy, 88, 120, true);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
// default icon must come first in icon_names
|
||||
|
||||
/* eslint-env node */
|
||||
|
||||
var imageconverter = require("../../../webtools/imageconverter.js");
|
||||
var icons = JSON.parse(require("fs").readFileSync(__dirname+"/icon_names.json"));
|
||||
const imgOptions = {
|
||||
|
|
|
@ -69,7 +69,7 @@ const drawMixedClock = function() {
|
|||
buf.drawString(dateArray[3], 237, 176, true);
|
||||
|
||||
// draw hour and minute dots
|
||||
for (i = 0; i < 60; i++) {
|
||||
for (let i = 0; i < 60; i++) {
|
||||
radius = (i % 5) ? 2 : 4;
|
||||
rotatePoint(0, Radius.dots, i * 6, Center, point);
|
||||
buf.fillCircle(point[0], point[1], radius);
|
||||
|
|
|
@ -21,7 +21,7 @@ function parseDevice(device) {
|
|||
var l = d.getUint8(offset+2);
|
||||
var code = d.getUint16(offset,true);
|
||||
if (!deviceInfo[device.id]) deviceInfo[device.id]={id:device.id};
|
||||
event = deviceInfo[device.id];
|
||||
let event = deviceInfo[device.id];
|
||||
switch (code) {
|
||||
case 0x1004: event.temperature = d.getInt16(offset+3,true)/10; break;
|
||||
case 0x1006: event.humidity = d.getInt16(offset+3)/10; break;
|
||||
|
|
|
@ -76,7 +76,7 @@ g.clear();
|
|||
loadSettings();
|
||||
loadThemeColors();
|
||||
|
||||
offset_widgets = settings.showWidgets ? 24 : 0;
|
||||
const offset_widgets = settings.showWidgets ? 24 : 0;
|
||||
let available_height = g.getHeight() - offset_widgets;
|
||||
|
||||
// Calculate grid size and offsets
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
const F = 132*H/240; // reasonable approximation
|
||||
|
||||
function drawTime() {
|
||||
d = new Date()
|
||||
const d = new Date()
|
||||
g.reset();
|
||||
var da = d.toString().split(" ");
|
||||
var time = da[4].substr(0, 5).split(":");
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
|
||||
function drawClock(){
|
||||
var now=Date();
|
||||
d=now.toString().split(' ');
|
||||
var min=d[4].substr(3,2);
|
||||
let d=now.toString().split(' ');
|
||||
//var min=d[4].substr(3,2);
|
||||
//var sec=d[4].substr(-2);
|
||||
var tm=d[4].substring(0,5);
|
||||
//var hr=d[4].substr(0,2);
|
||||
lastmin=min;
|
||||
//lastmin=min;
|
||||
g.reset();
|
||||
g.clearRect(0,24,W-1,H-1);
|
||||
g.setColor(g.theme.fg);
|
||||
|
|
|
@ -17,6 +17,7 @@ function hardMode(tries, max) {
|
|||
g.reset();
|
||||
g.setClipRect(R.x,R.y,R.x2,R.y2);
|
||||
var code = Math.abs(E.hwRand()%4);
|
||||
let dir;
|
||||
if (code == 0) dir = "up";
|
||||
else if (code == 1) dir = "right";
|
||||
else if (code == 2) dir = "down";
|
||||
|
|
|
@ -51,7 +51,7 @@ function setFromGPS() {
|
|||
}
|
||||
|
||||
function setFromWaypoint() {
|
||||
wpmenu = {
|
||||
const wpmenu = {
|
||||
'': { 'title': /*LANG*/'Waypoint' },
|
||||
'< Back': ()=>{ showMainMenu(); },
|
||||
};
|
||||
|
|
|
@ -115,7 +115,7 @@ function drawAnimated(){
|
|||
queueDraw();
|
||||
|
||||
// Animate draw through different colors
|
||||
speed = 25;
|
||||
const speed = 25;
|
||||
setTimeout(function() {
|
||||
_draw(false, 1);
|
||||
setTimeout(function() {
|
||||
|
|
|
@ -237,7 +237,7 @@ for (let idx=0; idx*2 < points6.length; idx++) {
|
|||
points9[idx*2+1] = 99-points6[idx*2+1];
|
||||
}
|
||||
|
||||
pointsArray = [points0, points1, points2, points3, points4, points5, points6, points7, points8, points9];
|
||||
const pointsArray = [points0, points1, points2, points3, points4, points5, points6, points7, points8, points9];
|
||||
|
||||
function eraseDigit(d, x, y) {
|
||||
if(d < 0 || d > 9) return;
|
||||
|
|
|
@ -274,7 +274,7 @@ function handleState(fastUpdate){
|
|||
// Set weather
|
||||
state.has_weather = true;
|
||||
try {
|
||||
weather = require('weather').get();
|
||||
const weather = require('weather').get();
|
||||
if (weather === undefined){
|
||||
state.has_weather = false;
|
||||
state.temp = "-";
|
||||
|
|
|
@ -325,7 +325,7 @@ function calculateValue(calculatedVariable, variableValues) {
|
|||
|
||||
// Move down for the next entry
|
||||
let nextTitleY = (i + 1 < titlePositions.length) ? titlePositions[i + 1] : titleY + 1.5 * fontSize + lineSpacing;
|
||||
yPosition = nextTitleY;
|
||||
//yPosition = nextTitleY;
|
||||
}
|
||||
g.flip();
|
||||
};
|
||||
|
|
|
@ -252,7 +252,7 @@ function showMap() {
|
|||
hasScrolled = true;
|
||||
drawLocation();
|
||||
} else if (hasScrolled) {
|
||||
delta = getTime() - startDrag;
|
||||
const delta = getTime() - startDrag;
|
||||
startDrag = 0;
|
||||
hasScrolled = false;
|
||||
if (delta < 0.2) {
|
||||
|
|
|
@ -297,17 +297,17 @@ function drawBorders() {
|
|||
}
|
||||
{
|
||||
d = new Date();
|
||||
sun = SunCalc.getTimes(d, lat, lon);
|
||||
const sun = SunCalc.getTimes(d, lat, lon);
|
||||
g.setColor(0.5, 0.5, 0);
|
||||
print("sun", sun);
|
||||
drawTimeIcon(sun.sunset, img_sunrise, { rotate: Math.PI, scale: 2 });
|
||||
drawTimeIcon(sun.sunrise, img_sunrise, { scale: 2 });
|
||||
g.setColor(0, 0, 0);
|
||||
moon = SunCalc.getMoonTimes(d, lat, lon);
|
||||
const moon = SunCalc.getMoonTimes(d, lat, lon);
|
||||
print("moon", moon);
|
||||
drawTimeIcon(moon.set, img_moonrise, { rotate: Math.PI, scale: 2 });
|
||||
drawTimeIcon(moon.rise, img_sunrise, { scale: 2 });
|
||||
pos = SunCalc.getPosition(d, lat, lon);
|
||||
let pos = SunCalc.getPosition(d, lat, lon);
|
||||
print("sun:", pos);
|
||||
if (pos.altitude > -0.1) {
|
||||
g.setColor(0.5, 0.5, 0);
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
E.showMenu(buildMainMenu());
|
||||
});
|
||||
} else {
|
||||
E.showPrompt("Install a text input lib"),then(()=>{
|
||||
E.showPrompt("Install a text input lib"),then(()=>{ // TODO: Should `,then` have been `.then` ?
|
||||
E.showMenu(buildMainMenu());
|
||||
});
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ let dark = g.theme.dark; // bool
|
|||
let gfx = function() {
|
||||
widgetUtils.hide();
|
||||
R = Bangle.appRect;
|
||||
marigin = 8;
|
||||
const marigin = 8;
|
||||
// g.drawString(str, x, y, solid)
|
||||
g.clearRect(R);
|
||||
g.reset();
|
||||
|
@ -53,9 +53,9 @@ let gfx = function() {
|
|||
|
||||
// Touch handler for main layout
|
||||
let touchHandler = function(_, xy) {
|
||||
x = xy.x;
|
||||
y = xy.y;
|
||||
len = (R.w<R.h+1)?(R.w/3):(R.h/3);
|
||||
let x = xy.x;
|
||||
let y = xy.y;
|
||||
let len = (R.w<R.h+1)?(R.w/3):(R.h/3);
|
||||
|
||||
// doing a<b+1 seemed faster than a<=b, also using a>b-1 instead of a>=b.
|
||||
if ((R.x-1<x && x<R.x+len) && (R.y-1<y && y<R.y+len)) {
|
||||
|
@ -142,7 +142,7 @@ let simpleSearchTerm = function() { // input a simple search term without tags,
|
|||
};
|
||||
|
||||
let searchPlayWOTags = function() { //make a search and play using entered terms
|
||||
searchString = simpleSearch;
|
||||
const searchString = simpleSearch;
|
||||
Bluetooth.println("");
|
||||
Bluetooth.println(JSON.stringify({
|
||||
t: "intent",
|
||||
|
|
|
@ -347,7 +347,7 @@ const events = {
|
|||
},
|
||||
|
||||
scan: function(now, from, to, f) {
|
||||
result = Infinity;
|
||||
let result = Infinity;
|
||||
let o = now.getTimezoneOffset() * 60000;
|
||||
let t = now.getTime() - o;
|
||||
let c, p, i, l = from - o, h = to - o;
|
||||
|
|
|
@ -92,7 +92,7 @@ const prepFont = (name, data) => {
|
|||
//const w0 = lengths[min];
|
||||
let widths = '';
|
||||
for (c = min, o = 0; c <= max; c++) {
|
||||
for (i = 0, j = offsets[c]; i < lengths[c]; i++) {
|
||||
for (let i = 0, j = offsets[c]; i < lengths[c]; i++) {
|
||||
xoffs[j] = asc + body + adjustments[c] - 1;
|
||||
ypos[j++] = o++;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ const prepFont = (name, data) => {
|
|||
return x;
|
||||
};
|
||||
|
||||
res = `
|
||||
let res = `
|
||||
const heatshrink = require('heatshrink');
|
||||
const dec = x => E.toString(heatshrink.decompress(atob(x)));
|
||||
`;
|
||||
|
|
|
@ -92,7 +92,7 @@ const prepFont = (name, data) => {
|
|||
//const w0 = lengths[min];
|
||||
let widths = '';
|
||||
for (c = min, o = 0; c <= max; c++) {
|
||||
for (i = 0, j = offsets[c]; i < lengths[c]; i++) {
|
||||
for (let i = 0, j = offsets[c]; i < lengths[c]; i++) {
|
||||
xoffs[j] = asc + body + adjustments[c] - 1;
|
||||
ypos[j++] = o++;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ const prepFont = (name, data) => {
|
|||
return x;
|
||||
};
|
||||
|
||||
res = `
|
||||
let res = `
|
||||
const heatshrink = require('heatshrink');
|
||||
const dec = x => E.toString(heatshrink.decompress(atob(x)));
|
||||
`;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
E.showMenu = function(items) {
|
||||
function RectRnd(x1,y1,x2,y2,r) {
|
||||
pp = [];
|
||||
let pp = [];
|
||||
pp.push.apply(pp,g.quadraticBezier([x2-r,y1, x2,y1,x2,y1+r]));
|
||||
pp.push.apply(pp,g.quadraticBezier([x2,y2-r,x2,y2,x2-r,y2]));
|
||||
pp.push.apply(pp,g.quadraticBezier([x1+r,y2,x1,y2,x1,y2-r]));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
E.showMenu = function(items) {
|
||||
function RectRnd(x1,y1,x2,y2,r) {
|
||||
pp = [];
|
||||
let pp = [];
|
||||
pp.push.apply(pp,g.quadraticBezier([x2-r,y1, x2,y1,x2,y1+r]));
|
||||
pp.push.apply(pp,g.quadraticBezier([x2,y2-r,x2,y2,x2-r,y2]));
|
||||
pp.push.apply(pp,g.quadraticBezier([x1+r,y2,x1,y2,x1,y2-r]));
|
||||
|
|
|
@ -143,7 +143,7 @@
|
|||
showMainMenu();
|
||||
};
|
||||
let timeoutvalues = [10,20,30,60];
|
||||
for (c in timeoutvalues){
|
||||
for (const c in timeoutvalues){
|
||||
let v = timeoutvalues[c];
|
||||
timeoutMenu[v+"s"] = function () {
|
||||
save("timeout", v);
|
||||
|
|
|
@ -105,12 +105,12 @@ function drawStrCenter(str, colour) {
|
|||
g.setColor(colour);
|
||||
g.setFont("Vector", 13);
|
||||
str = "\"" + str + "\"";
|
||||
maxLength = 24;
|
||||
const maxLength = 24;
|
||||
var ta = [];
|
||||
let index = 0;
|
||||
let linestart = 0;
|
||||
while (index < str.length) {
|
||||
newIndex = str.indexOf(" ", index);
|
||||
const newIndex = str.indexOf(" ", index);
|
||||
if (newIndex == -1) {
|
||||
if ((str.length - linestart) > maxLength) {
|
||||
ta.push(str.substring(linestart, index));
|
||||
|
@ -122,7 +122,7 @@ function drawStrCenter(str, colour) {
|
|||
linestart = index;
|
||||
} else index = newIndex + 1;
|
||||
}
|
||||
y = 110 - ta.length * 5;
|
||||
let y = 110 - ta.length * 5;
|
||||
ta.forEach((e) => {
|
||||
g.setFontAlign(0, -1).drawString(e.trim(), 88, y);
|
||||
y += 12;
|
||||
|
|
|
@ -110,8 +110,8 @@ function showCardMenu() {
|
|||
},
|
||||
'Go': () => {
|
||||
n = Math.min(n, 52);
|
||||
SUITS = ['Spades', 'Diamonds', 'Clubs', 'Hearts'];
|
||||
RANKS = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King'];
|
||||
const SUITS = ['Spades', 'Diamonds', 'Clubs', 'Hearts'];
|
||||
const RANKS = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King'];
|
||||
class Card {
|
||||
constructor(suit, rank) {
|
||||
this.suit = suit;
|
||||
|
|
|
@ -90,17 +90,17 @@ const drawSecArc = function (sections, color) {
|
|||
|
||||
const drawClock = function () {
|
||||
g.reset();
|
||||
currentTime = new Date();
|
||||
let currentTime = new Date();
|
||||
|
||||
//Set to initial time when started
|
||||
if (first == true) {
|
||||
minutes = currentTime.getMinutes();
|
||||
seconds = currentTime.getSeconds();
|
||||
for (count = 0; count <= minutes; count++) {
|
||||
for (let count = 0; count <= minutes; count++) {
|
||||
drawMinArc(count, settings.circle.colormin);
|
||||
}
|
||||
|
||||
for (count = 0; count <= seconds; count++) {
|
||||
for (let count = 0; count <= seconds; count++) {
|
||||
drawSecArc(count, settings.circle.colorsec);
|
||||
}
|
||||
first = false;
|
||||
|
@ -110,7 +110,7 @@ const drawClock = function () {
|
|||
if (seconds == 59) {
|
||||
g.setColor('#000000');
|
||||
g.fillCircle(settings.circle.middle, settings.circle.center, (settings.circle.height / 2));
|
||||
for (count = 0; count <= minutes; count++) {
|
||||
for (let count = 0; count <= minutes; count++) {
|
||||
drawMinArc(count, settings.circle.colormin);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -313,7 +313,7 @@ Graphics.prototype.setFontKdamThmor = function(scale) {
|
|||
if( Bangle.isCharging() )
|
||||
{
|
||||
g.setBgColor(settings.bg);
|
||||
image = ()=> { return require("heatshrink").decompress(atob("j8OwMB/4AD94DC44DCwP//n/gH//EOgE/+AdBh/gAYMH4EAvkDAYP/+/AFAX+FgfzGAnAA=="));}
|
||||
const image = ()=> { return require("heatshrink").decompress(atob("j8OwMB/4AD94DC44DCwP//n/gH//EOgE/+AdBh/gAYMH4EAvkDAYP/+/AFAX+FgfzGAnAA=="));}
|
||||
g.drawImage(image(),x+3,y+4);
|
||||
}
|
||||
|
||||
|
|
|
@ -250,8 +250,8 @@
|
|||
let oldPoly2 = CLEAR_POLYS_2[0];
|
||||
doAnim(i => {
|
||||
i = ease(i);
|
||||
poly1 = interpolatePoly(CLEAR_POLYS_1, i);
|
||||
poly2 = interpolatePoly(CLEAR_POLYS_2, i);
|
||||
const poly1 = interpolatePoly(CLEAR_POLYS_1, i);
|
||||
const poly2 = interpolatePoly(CLEAR_POLYS_2, i);
|
||||
// Fill in black line
|
||||
g.setColor(TEXT_COLOR);
|
||||
g.fillPoly(poly1);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
g.setFontAlign(-1, 0);
|
||||
|
||||
// draw time
|
||||
let t;
|
||||
if (m >= 0 && m < 2) {
|
||||
t = leshores[d.getHours()] + "\r\nen punt";
|
||||
} else if (m >= 2 && m < 5) {
|
||||
|
|
|
@ -145,7 +145,7 @@ function drawMonthCircleText( text, circleSize, range, value){
|
|||
grimg.transparent = 1;
|
||||
monthCircleTextBuffer.setColor(1,1,1);
|
||||
|
||||
for(z=0; z < text.length; z++){
|
||||
for(let z=0; z < text.length; z++){
|
||||
tobj = { x:watch.screen.centerX, y:watch.screen.centerY, scale:1, rotate: ((z + 1) / range) * (Math.PI * 2) };
|
||||
tver = [-1, 0, 1, 0, 1, -circleSize, -1, -(circleSize -21)];
|
||||
tran = monthCircleTextBuffer.transformVertices(tver, tobj);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
// Only update the file if the clock really changed to be nice to the FLASH mem
|
||||
if (clockApps[clockIndex].src != currentClock) {
|
||||
currentClock = clockApps[clockIndex].src;
|
||||
settings = require("Storage").readJSON('setting.json', 1);
|
||||
const settings = require("Storage").readJSON('setting.json', 1);
|
||||
settings.clock = clockApps[clockIndex].src;
|
||||
require("Storage").write('setting.json', settings);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
Bangle.setLCDPower(1);
|
||||
Bangle.setLCDTimeout(0);
|
||||
g.reset();
|
||||
c = 1;
|
||||
let c = 1;
|
||||
|
||||
function setColor(delta){
|
||||
c+=delta;
|
||||
|
|
|
@ -16,9 +16,9 @@ let paused = false;
|
|||
const SCAN_FREQ = 1000 * 30;
|
||||
|
||||
// ALERT LIMITS
|
||||
LIMIT_SAUNA = 60;
|
||||
LIMIT_FRIDGE = 4;
|
||||
LIMIT_FREEZER = -18;
|
||||
const LIMIT_SAUNA = 60;
|
||||
const LIMIT_FRIDGE = 4;
|
||||
const LIMIT_FREEZER = -18;
|
||||
// TODO add wine cellar limits
|
||||
// TODO configurable limits
|
||||
|
||||
|
|
|
@ -96,7 +96,6 @@ function setupMatch() {
|
|||
|
||||
function showSettingsMenu() {
|
||||
settingsMenuOpened = getSecondsTime();
|
||||
l = null;
|
||||
settingsMenu(function (s, reset) {
|
||||
E.showMenu();
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ function drawHands() {
|
|||
else {g.setColor(g.theme.bg);}
|
||||
g.drawString(weekDay[0].toUpperCase(), 137, 90);
|
||||
|
||||
handLayers = [
|
||||
const handLayers = [
|
||||
{x:cx,
|
||||
y:cy,
|
||||
image:imgHour,
|
||||
|
@ -148,7 +148,7 @@ function drawBackground() {
|
|||
g.clear(1);
|
||||
g.setBgColor(g.theme.bg);
|
||||
g.setColor(g.theme.fg);
|
||||
bgLayer = [
|
||||
const bgLayer = [
|
||||
{x:cx,
|
||||
y:cy,
|
||||
image:imgBg,
|
||||
|
|
|
@ -761,7 +761,7 @@ function showLauncherMenu() {
|
|||
}
|
||||
|
||||
function showSetTimeMenu() {
|
||||
d = new Date();
|
||||
let d = new Date();
|
||||
const timemenu = {
|
||||
'': { 'title': /*LANG*/'Date & Time' },
|
||||
'< Back': function () {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
g.reset();
|
||||
g.clear();
|
||||
g.drawImage(require("Storage").read("showimg.user.img"),0,0);
|
||||
drawTimeout = setTimeout(function() {
|
||||
/*let drawTimeout =*/ setTimeout(function() {
|
||||
load();
|
||||
}, 60000);
|
||||
setWatch(function() {
|
||||
|
|
|
@ -329,7 +329,7 @@ function drawClock() {
|
|||
y=0;
|
||||
buf.setFontAlign(1,-1);
|
||||
buf.setFontVector(94);
|
||||
time = require("locale").time(new Date(),1);
|
||||
const time = require("locale").time(new Date(),1);
|
||||
|
||||
buf.setColor(1);
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@ Peter Bernschneider 30.12.2021
|
|||
Update current latitude and longitude in My Location app
|
||||
Update current Timezone in Settings app, menu item "System"
|
||||
Update for summer time by incrementing Timezone += 1 */
|
||||
setting = require("Storage").readJSON("setting.json",1);
|
||||
const setting = require("Storage").readJSON("setting.json",1);
|
||||
E.setTimeZone(setting.timezone); // timezone = 1 for MEZ, = 2 for MESZ
|
||||
SunCalc = require("suncalc.js");
|
||||
loc = require('locale');
|
||||
const SunCalc = require("suncalc.js");
|
||||
const loc = require('locale');
|
||||
const LOCATION_FILE = "mylocation.json";
|
||||
const xyCenter = g.getWidth() / 2 + 3;
|
||||
const yposTime = 60;
|
||||
|
@ -28,9 +28,9 @@ function updatePos() {
|
|||
altitude: Math.round( pos.altitude / rad)
|
||||
};
|
||||
}
|
||||
coord = require("Storage").readJSON(LOCATION_FILE,1)|| {"lat":53.3,"lon":10.1,"location":"Pattensen"};
|
||||
const coord = require("Storage").readJSON(LOCATION_FILE,1)|| {"lat":53.3,"lon":10.1,"location":"Pattensen"};
|
||||
pos = radToDeg(SunCalc.getPosition(Date.now(), coord.lat, coord.lon));
|
||||
times = SunCalc.getTimes(Date.now(), coord.lat, coord.lon);
|
||||
const times = SunCalc.getTimes(Date.now(), coord.lat, coord.lon);
|
||||
rise = times.sunrise.toString().split(" ")[4].substr(0,5);
|
||||
set = times.sunset.toString().split(" ")[4].substr(0,5);
|
||||
noonpos = radToDeg(SunCalc.getPosition(times.solarNoon, coord.lat, coord.lon));
|
||||
|
|
|
@ -88,7 +88,7 @@ Date.prototype.sunriseSet = function (latitude, longitude, sunrise, zenith) {
|
|||
|
||||
sinDec = 0.39782 * Math.sinDeg(sunTrueLongitude);
|
||||
cosDec = Math.cosDeg(Math.asinDeg(sinDec));
|
||||
cosLocalHourAngle = ((Math.cosDeg(zenith)) - (sinDec * (Math.sinDeg(latitude)))) / (cosDec * (Math.cosDeg(latitude)));
|
||||
const cosLocalHourAngle = ((Math.cosDeg(zenith)) - (sinDec * (Math.sinDeg(latitude)))) / (cosDec * (Math.cosDeg(latitude)));
|
||||
|
||||
localHourAngle = Math.acosDeg(cosLocalHourAngle);
|
||||
|
||||
|
@ -190,7 +190,7 @@ function drawSinuses () {
|
|||
g.setColor(1, 1, 1);
|
||||
let y = ypos(x);
|
||||
while (x < w) {
|
||||
y2 = ypos(x + sinStep);
|
||||
const y2 = ypos(x + sinStep);
|
||||
g.drawLine(x, y, x + sinStep, y2);
|
||||
y = y2;
|
||||
x += sinStep; // no need to draw all steps
|
||||
|
|
|
@ -46,10 +46,10 @@ const drawBanner = (h) =>{
|
|||
const updateTimeBanner = (h,m)=>{
|
||||
m = (m<10?'0':'')+m;
|
||||
h = (h<10?'0':'')+h;
|
||||
bx1=g.getWidth()/2-90;
|
||||
by1=50+10;
|
||||
bx2=g.getWidth()/2+90;
|
||||
by2=50+62;
|
||||
const bx1=g.getWidth()/2-90;
|
||||
const by1=50+10;
|
||||
const bx2=g.getWidth()/2+90;
|
||||
const by2=50+62;
|
||||
|
||||
g.setFontCustom(eval(s.read("supmario30x24.bin")), 48, eval(s.read("supmario30x24.wdt")), 24);
|
||||
g.setClipRect(bx1,by1,bx2,by2).clearRect(bx1,by1,bx2,by2);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
}
|
||||
|
||||
function appMenu() {
|
||||
menu = {
|
||||
let menu = {
|
||||
"" : { "title" : /*LANG*/"Swipe inversion apps" },
|
||||
"< Back" : () => { writeSettings(); mainMenu();}
|
||||
};
|
||||
|
|
|
@ -34,7 +34,7 @@ Bangle.setUI({
|
|||
remove : options.remove,
|
||||
redraw : draw,
|
||||
swipe : (_,UD)=>{
|
||||
pixels = 120;
|
||||
const pixels = 120;
|
||||
var dy = UD*pixels;
|
||||
if (s.scroll - dy > menuScrollMax)
|
||||
dy = s.scroll - menuScrollMax-8; // Makes it so the last 'page' has the same position as previous pages. This should be done dynamically (change the static 8 to be a variable) so the offset is correct even when no widget field or title field is present.
|
||||
|
|
|
@ -701,7 +701,7 @@ function probe() {
|
|||
stride = 68;
|
||||
}
|
||||
*/
|
||||
stride = 68;
|
||||
let stride = 68;
|
||||
|
||||
lcdBuffer = start;
|
||||
print('Found lcdBuffer at ' + lcdBuffer.toString(16) + ' stride=' + stride);
|
||||
|
|
|
@ -22,7 +22,7 @@ function appTitle() {
|
|||
}
|
||||
|
||||
function currentTime() {
|
||||
min = Date().getMinutes();
|
||||
let min = Date().getMinutes();
|
||||
if (min < 10) min = "0" + min;
|
||||
return Date().getHours() + ":" + min;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,8 @@ if (readFreq>saveFreq) console.log("Read refresh freq should be higher than savi
|
|||
if (v_mode_debug>0) console.log("original BG/FG color="+v_color_erase+" / "+v_color);
|
||||
|
||||
|
||||
|
||||
let v_font_size1;
|
||||
let v_font_size2;
|
||||
function SetVariables(){
|
||||
//EMSCRIPTEN,EMSCRIPTEN2
|
||||
if (v_model=='BANGLEJS'||v_model=='EMSCRIPTEN') {
|
||||
|
@ -209,7 +210,7 @@ g.drawString("Mode debug: "+v_mode_debug, x, y - ((v_font_size1*1)+2));
|
|||
g.drawString("Read frq(ms): "+readFreq, x, y );
|
||||
g.drawString("Save file: "+v_saveToFile, x, y+ ((v_font_size1*1)+2) );
|
||||
g.drawString("Save frq(ms):"+saveFreq, x, y+((v_font_size1*2)+2) );
|
||||
fr=require("Storage").read(v_filename+"\1");//suffix required
|
||||
const fr=require("Storage").read(v_filename+"\1");//suffix required
|
||||
if (fr) g.drawString("Filesize:"+fr.length.toString()+"kb", x, y+((v_font_size1*3)+2) );
|
||||
else g.drawString("File not exist", x, y+((v_font_size1*3)+2));
|
||||
}
|
||||
|
|
|
@ -156,6 +156,7 @@ function PrintUserInput(boton){
|
|||
//Call info banner
|
||||
g.setFontVector(30).drawString(boton, 63, 55);
|
||||
if ((boton=='Touch 1')||(boton=='Touch 2')){
|
||||
let v_y_opt;
|
||||
if (v_selected_row==1) v_y_opt=v_y_optionrow1;
|
||||
else if (v_selected_row==2) v_y_opt=v_y_optionrow2;
|
||||
DrawRoundOption(20,v_y_opt,190,v_y_opt,boton);
|
||||
|
|
|
@ -69,7 +69,7 @@ function calcWin(){
|
|||
|
||||
//draw check
|
||||
// drawChk is sum absolute value of array, if drawChk = 9 then there is a draw
|
||||
drawChk = 0;
|
||||
let drawChk = 0;
|
||||
for(let i = 0; i<3; i++){
|
||||
for(let j = 0; j<3; j++){
|
||||
drawChk = drawChk + Math.abs(arr[i][j]);
|
||||
|
@ -94,6 +94,7 @@ function calcWin(){
|
|||
|
||||
function draw(){
|
||||
g.clear();
|
||||
let playerIcon;
|
||||
if (player ==1){
|
||||
playerIcon = "X";
|
||||
} else if(player == -1){
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue