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