forked from FOSS/BangleApps
Merge branch 'app/hc-clock' of github.com:peeweek/BangleApps into app/hc-clock
commit
00b6f29b94
292
app.js
292
app.js
|
@ -1,292 +0,0 @@
|
|||
|
||||
/**
|
||||
* Widget measurements
|
||||
* Description:
|
||||
* name: connection.wid.js
|
||||
*icon: conectionIcon.icon
|
||||
*
|
||||
*/
|
||||
|
||||
//Font
|
||||
g.setFont("Vector", 100);
|
||||
//variabangle.Sensorss
|
||||
let acclS, bttS, compssS, gpsS, hrmS, stepS; //Strings
|
||||
let accelN, compssN, gpsN, hrmN, stepN; //Num
|
||||
let prueba = 1;
|
||||
let data = [0, 0, 0, 0, 0, 0];
|
||||
//Constants for redabangle.Sensors code
|
||||
let storage = require('Storage');
|
||||
let deCom = require('heatshrink');
|
||||
|
||||
|
||||
|
||||
|
||||
//Sensors code
|
||||
/**
|
||||
*
|
||||
* @author Jorge
|
||||
*/
|
||||
function accel() {
|
||||
|
||||
Bangle.on('accel', function (acc) {
|
||||
// acc = {x,y,z,diff,mag}
|
||||
accelN = acc;
|
||||
});
|
||||
|
||||
setInterval(function () {
|
||||
|
||||
acclS = accelN.x + "##" + accelN.y + "##" + accelN.z + "\n" + accelN.diff + "##" + accelN.mag;
|
||||
data[3] = accelN;
|
||||
}, 2 * 1000);
|
||||
|
||||
}
|
||||
|
||||
function btt() {
|
||||
|
||||
setInterval(function () {
|
||||
|
||||
bttS = E.getBattery(); //return String
|
||||
data[2] = E.getBattery();
|
||||
}, 15 * 1000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function compss() {
|
||||
|
||||
Bangle.setCompassPower(1);
|
||||
Bangle.on('mag', function (mag) {
|
||||
// mag = {x,y,z,dx,dy,dz,heading}
|
||||
compssN = mag;
|
||||
});
|
||||
|
||||
|
||||
setInterval(function () {
|
||||
|
||||
compssS = "A: " + compssN.x + " ## " + compssN.y + " ## " + compssN.z + "\n" +
|
||||
"B: " + compssN.dx + " ## " + compssN.dy + " ## " + compssN.dz + " ## " + "\n" +
|
||||
"C: " + compssN.heading; //return String
|
||||
data[4] = compssN;
|
||||
}, 2 * 1000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function gps() {
|
||||
|
||||
Bangle.setGPSPower(1);
|
||||
Bangle.on('GPS', function (gps) {
|
||||
// gps = {lat,lon,alt,speed,etc}
|
||||
gpsN = gps;
|
||||
|
||||
});
|
||||
|
||||
setInterval(function () {
|
||||
|
||||
gpsS = "A: " + gpsN.lat + " ## " + gpsN.lon + " ## " + gpsN.alt + "\n" + "B: " + gpsN.speed + " ## " + gpsN.course + " ## " + gpsN.time + "\n" +
|
||||
"C: " + gpsN.satellites + " ## " + gpsN.fix; //return String
|
||||
// work out how to display the current time
|
||||
var d = new Date();
|
||||
var year = d.getFullYear();
|
||||
|
||||
var month = d.getMonth() + 1;
|
||||
var finalMonth = 0;
|
||||
if (month < 10) {
|
||||
finalMonth = "0" + month;
|
||||
} else {
|
||||
finalMonth = month;
|
||||
}
|
||||
var day = d.getDate();
|
||||
var finalDay = 0;
|
||||
if (day < 10) {
|
||||
finalDay = "0" + day;
|
||||
} else {
|
||||
finalDay = day;
|
||||
}
|
||||
var h = d.getHours(),
|
||||
m = d.getMinutes();
|
||||
var finalh = 0;
|
||||
if (h < 10) {
|
||||
finalh = "0" + h;
|
||||
} else {
|
||||
finalh = h;
|
||||
}
|
||||
var finalM = 0;
|
||||
if (m < 10) {
|
||||
finalM = "0" + m;
|
||||
} else {
|
||||
finalM = m;
|
||||
}
|
||||
|
||||
var s = d.getSeconds();
|
||||
var finalS = 0;
|
||||
if (s < 10) {
|
||||
finalS = "0" + s;
|
||||
} else {
|
||||
finalS = s;
|
||||
}
|
||||
var z = d.getMilliseconds();
|
||||
var zFinal = new String(z);
|
||||
zFinal = zFinal.replace('.', '');
|
||||
var completeTime = year + "-" + finalMonth + "-" + finalDay + "T" + finalh + ":" + finalM + ":" + finalS + "." + z + "Z";
|
||||
var time = h + ":" + ("0" + m).substr(-2);
|
||||
gpsN.time = completeTime;
|
||||
data[5] = gpsN;
|
||||
}, 2 * 1000);
|
||||
}
|
||||
|
||||
//2021-06-11T19:21:58.000Z
|
||||
|
||||
function hrm() {
|
||||
|
||||
let msr = [0, 0, 0, 0, 0];
|
||||
let lastInsert = -1;
|
||||
|
||||
function roundInsert(nueva) {
|
||||
let indexFinal = (lastInsert + 1) % (msr.length);
|
||||
//console.log("Index ==> "+ index);
|
||||
msr[indexFinal] = nueva;
|
||||
|
||||
item = nueva;
|
||||
lastInsert = indexFinal;
|
||||
|
||||
}
|
||||
|
||||
function normalize(nueva) {
|
||||
|
||||
let normalize = 0;
|
||||
roundInsert(nueva);
|
||||
|
||||
|
||||
msr.forEach(function (number) {
|
||||
normalize += number;
|
||||
});
|
||||
normalize = normalize / msr.length;
|
||||
|
||||
return normalize;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
setInterval(function () {
|
||||
|
||||
if (!isNaN(hrmN)) {
|
||||
|
||||
|
||||
hrmN = normalize(hrmN);
|
||||
var roundedRate = parseFloat(hrmN).toFixed(2);
|
||||
hrmS = String.valueOf(roundedRate); //return String
|
||||
//console.log("array----->" + msr);
|
||||
data[0] = roundedRate;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}, 2 * 1000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function steps() {
|
||||
|
||||
Bangle.on('step', s => {
|
||||
|
||||
stepN = s;
|
||||
});
|
||||
|
||||
|
||||
setInterval(function () {
|
||||
|
||||
stepS = String.valueOf(stepN); //return String
|
||||
data[1] = stepN;
|
||||
}, 2 * 1000);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function initSensors() {
|
||||
|
||||
//need power control
|
||||
Bangle.setHRMPower(1);
|
||||
|
||||
Bangle.on('HRM', function (hrm) {
|
||||
hrmN = hrm.bpm;
|
||||
|
||||
|
||||
});
|
||||
console.log("Sensors are being Init....");
|
||||
accel();
|
||||
btt();
|
||||
compss();
|
||||
gps();
|
||||
hrm();
|
||||
steps();
|
||||
|
||||
}
|
||||
|
||||
var flip = 1;
|
||||
Bangle.on('lcdPower', function (on) {
|
||||
/*
|
||||
prueba ++;
|
||||
Bangle.drawWidgets();
|
||||
g.setFont("Vector", 45);
|
||||
g.drawString(prueba,100,200);*/
|
||||
if (flip == 1) { //when off
|
||||
|
||||
flip = 0;
|
||||
//Bangle.buzz(1000);
|
||||
g.clear();
|
||||
} else { //when on
|
||||
|
||||
flip = 1;
|
||||
g.setFont("Vector", 30);
|
||||
g.drawString(data[0], 65, 180);
|
||||
Bangle.drawWidgets();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
function draw() {
|
||||
|
||||
g.drawImage(storage.read("iconWatch.img"), this.x + 1, this.y + 1);
|
||||
g.drawImage(storage.read("heart.img"), 145, 167);
|
||||
}
|
||||
|
||||
|
||||
|
||||
initSensors();
|
||||
// Bangle.drawWidgets();
|
||||
// Terminal.println("Running BangleBridge");
|
||||
data[0] = 80.5;
|
||||
g.setFont("Vector", 30);
|
||||
g.drawString(data[0], 65, 180);
|
||||
Bangle.drawWidgets();
|
||||
setInterval(function () {
|
||||
//console.log("---------------------------------------------------------------");
|
||||
//console.log(data);
|
||||
//Bluetooth.println(data[0]);
|
||||
var measurement = {
|
||||
hrm: data[0],
|
||||
step: data[1],
|
||||
batt: data[2],
|
||||
acc: data[3],
|
||||
com: data[4],
|
||||
gps: data[5]
|
||||
};
|
||||
/* g.clear();
|
||||
g.drawString(compssS,100,200);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
Bluetooth.println(JSON.stringify(measurement) + "#");
|
||||
|
||||
}, 5 * 1000);
|
50
apps.json
50
apps.json
|
@ -4,7 +4,7 @@
|
|||
"tags": "tool,system,b2",
|
||||
"type":"bootloader",
|
||||
"icon": "bootloader.png",
|
||||
"version":"0.27",
|
||||
"version":"0.28",
|
||||
"description": "This is needed by Bangle.js to automatically load the clock, menu, widgets and settings",
|
||||
"storage": [
|
||||
{"name":".boot0","url":"boot0.js"},
|
||||
|
@ -533,7 +533,7 @@
|
|||
{ "id": "files",
|
||||
"name": "App Manager",
|
||||
"icon": "files.png",
|
||||
"version":"0.06",
|
||||
"version":"0.07",
|
||||
"description": "Show currently installed apps, free space, and allow their deletion from the watch",
|
||||
"tags": "tool,system,files",
|
||||
"storage": [
|
||||
|
@ -1244,6 +1244,19 @@
|
|||
{"name":"torch.img","url":"app-icon.js","evaluate":true}
|
||||
]
|
||||
},
|
||||
{ "id": "rtorch",
|
||||
"name": "Red Torch",
|
||||
"shortName":"RedTorch",
|
||||
"icon": "app.png",
|
||||
"version":"0.01",
|
||||
"description": "Turns screen RED to help you see in the dark without breaking your night vision. Select from the launcher or press BTN3,BTN1,BTN3,BTN1 quickly to start when in any app that shows widgets",
|
||||
"tags": "tool,torch",
|
||||
"storage": [
|
||||
{"name":"rtorch.app.js","url":"app.js"},
|
||||
{"name":"rtorch.wid.js","url":"widget.js"},
|
||||
{"name":"rtorch.img","url":"app-icon.js","evaluate":true}
|
||||
]
|
||||
},
|
||||
{ "id": "wohrm",
|
||||
"name": "Workout HRM",
|
||||
"icon": "app.png",
|
||||
|
@ -1746,7 +1759,7 @@
|
|||
"name": "Black Jack game",
|
||||
"shortName":"Black Jack game",
|
||||
"icon": "blackjack.png",
|
||||
"version":"0.01",
|
||||
"version":"0.02",
|
||||
"description": "Simple implementation of card game Black Jack",
|
||||
"tags": "game",
|
||||
"allow_emulator":true,
|
||||
|
@ -2097,6 +2110,20 @@
|
|||
{ "name": "jbm8b.img", "url": "app-icon.js", "evaluate": true }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "jbm8b_IT",
|
||||
"name": "Magic 8 Ball Italiano",
|
||||
"shortName": "Magic 8 Ball IT",
|
||||
"icon": "app.png",
|
||||
"description": "La palla predice il futuro",
|
||||
"tags": "game",
|
||||
"version": "0.03",
|
||||
"allow_emulator":true,
|
||||
"storage": [
|
||||
{ "name": "jbm8b_IT.app.js", "url": "app.js" },
|
||||
{ "name": "jbm8b_IT.img", "url": "app-icon.js", "evaluate": true }
|
||||
]
|
||||
},
|
||||
{ "id": "BLEcontroller",
|
||||
"name": "BLE Customisable Controller with Joystick",
|
||||
"shortName": "BLE Controller",
|
||||
|
@ -2667,7 +2694,7 @@
|
|||
{ "id": "dtlaunch",
|
||||
"name": "Desktop Launcher",
|
||||
"icon": "icon.png",
|
||||
"version":"0.03",
|
||||
"version":"0.04",
|
||||
"description": "Desktop style App Launcher with six apps per page - fast access if you have lots of apps installed.",
|
||||
"readme": "README.md",
|
||||
"tags": "tool,system,launcher",
|
||||
|
@ -3183,7 +3210,7 @@
|
|||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"banglebridge.wid.js","url":"widget.js"},
|
||||
{"name":"iconWatch.png","url":"iconWatch.png"},
|
||||
{"name":"iconWatch.png","url":"iconWatch.png"},
|
||||
{"name":"heart.png","url":"heart.png"}
|
||||
]
|
||||
},
|
||||
|
@ -3264,7 +3291,7 @@
|
|||
"name":"Dozenal Time",
|
||||
"shortName":"Dozenal Time",
|
||||
"icon":"app.png",
|
||||
"version":"0.01",
|
||||
"version":"0.04",
|
||||
"description":"A dozenal Holocene calendar and dozenal diurnal clock",
|
||||
"tags":"clock",
|
||||
"type":"clock",
|
||||
|
@ -3344,5 +3371,16 @@
|
|||
{"name":"hcclock.app.js","url":"hcclock.app.js"},
|
||||
{"name":"hcclock.img","url":"hcclock-icon.js","evaluate":true}
|
||||
]
|
||||
},
|
||||
{ "id": "thermomF",
|
||||
"name": "Fahrenheit Temp",
|
||||
"icon": "thermf.png",
|
||||
"version":"0.01",
|
||||
"description": "A modification of the Thermometer App to display temprature in Fahrenheit",
|
||||
"tags": "tool",
|
||||
"storage": [
|
||||
{"name":"thermomF.app.js","url":"app.js"},
|
||||
{"name":"thermomF.img","url":"app-icon.js","evaluate":true}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
0.01: New game! BTN4- Hit card, BTN5- Stand
|
||||
0.02: ignore buttons on pauses
|
|
@ -18,6 +18,7 @@ const Diamonds = { width : 48, height : 48, bpp : 4,
|
|||
var deck = [];
|
||||
var player = {Hand:[]};
|
||||
var computer = {Hand:[]};
|
||||
var ctx = {ready:true};
|
||||
|
||||
function createDeck() {
|
||||
var suits = ["Spades", "Hearts", "Diamonds", "Clubs"];
|
||||
|
@ -44,6 +45,7 @@ function shuffle(a) {
|
|||
}
|
||||
|
||||
function EndGameMessdage(msg){
|
||||
ctx.ready = false;
|
||||
g.drawString(msg, 155, 200);
|
||||
setTimeout(function(){
|
||||
startGame();
|
||||
|
@ -52,6 +54,7 @@ function EndGameMessdage(msg){
|
|||
}
|
||||
|
||||
function hitMe() {
|
||||
if (!ctx.ready) return;
|
||||
player.Hand.push(deck.pop());
|
||||
renderOnScreen(1);
|
||||
var playerWeight = calcWeight(player.Hand, 0);
|
||||
|
@ -97,6 +100,8 @@ function calcWeight(hand, hideCard) {
|
|||
}
|
||||
|
||||
function stand(){
|
||||
if (!ctx.ready) return;
|
||||
ctx.ready = false;
|
||||
function sleepFor( sleepDuration ){
|
||||
console.log("Sleeping...");
|
||||
var now = new Date().getTime();
|
||||
|
@ -156,6 +161,7 @@ function renderOnScreen(HideCard) {
|
|||
function dealHands() {
|
||||
player.Hand= [];
|
||||
computer.Hand= [];
|
||||
ctx.ready = false;
|
||||
|
||||
setTimeout(function(){
|
||||
player.Hand.push(deck.pop());
|
||||
|
@ -175,6 +181,7 @@ function dealHands() {
|
|||
setTimeout(function(){
|
||||
computer.Hand.push(deck.pop());
|
||||
renderOnScreen(1);
|
||||
ctx.ready = true;
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,3 +26,4 @@
|
|||
0.25: Fix error in 'no clock app' message
|
||||
0.26: Remove buzz in setUI polyfill (#750)
|
||||
0.27: Update polyfill for most recent changes
|
||||
0.28: Fix double clock load after settings are changed
|
||||
|
|
|
@ -136,8 +136,9 @@ require('Storage').list(/\.boot\.js/).forEach(bootFile=>{
|
|||
boot += "//"+bootFile+"\n"+require('Storage').read(bootFile)+"\n";
|
||||
});
|
||||
boot += "}\n";// initial 'if'
|
||||
var s = require('Storage').write('.boot0',boot);
|
||||
require('Storage').write('.boot0',boot);
|
||||
delete boot;
|
||||
E.showMessage("Reloading...");
|
||||
eval(require('Storage').read('.boot0'));
|
||||
eval(require('Storage').read('.bootcde'));
|
||||
// .bootcde should be run automatically after if required, since
|
||||
// we normally get called automatically from '.boot0'
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
0.01: New App!
|
||||
0.02 added emulator capability and display of widgets
|
||||
0.03 bug of advancing time fixed; doztime now correct within ca. 1 second
|
||||
0.04 changed time colour from slightly off white to pure white
|
||||
|
|
|
@ -13,11 +13,11 @@ const g_height_t = 48; // height of time region
|
|||
const A1 = [30,30,30,30,31,31,31,31,31,31,30,30];
|
||||
const B1 = [30,30,30,30,30,31,31,31,31,31,30,30];
|
||||
const B2 = [30,30,30,30,31,31,31,31,31,30,30,30];
|
||||
const timeColour = "#f2f2f2";
|
||||
const timeColour = "#ffffff";
|
||||
const dateColours = ["#ff0000","#ffa500","#ffff00","#00b800","#0000ff","#ff00ff","#ff0080"];
|
||||
const calen10 = {"size":32,"pt0":[32-g_x_off,16],"step":[20,0],"dx":-4.5,"dy":-4.5}; // positioning for usual calendar line
|
||||
const calen7 = {"size":32,"pt0":[62-g_x_off,16],"step":[20,0],"dx":-4.5,"dy":-4.5}; // positioning for S-day calendar line
|
||||
const time5 = {"size":48,"pt0":[64-g_x_off,24],"step":[30,0],"dx":-6.5,"dy":-6.5}; // positioning for lull time line; was 64
|
||||
const time5 = {"size":48,"pt0":[64-g_x_off,24],"step":[30,0],"dx":-6.5,"dy":-6.5}; // positioning for lull time line
|
||||
const time6 = {"size":48,"pt0":[48-g_x_off,24],"step":[30,0],"dx":-6.5,"dy":-6.5}; // positioning for twinkling time line
|
||||
const baseYear = 11584;
|
||||
const baseDate = Date(2020,11,21); // month values run from 0 to 11
|
||||
|
@ -30,8 +30,11 @@ let lastX = 999999999;
|
|||
let res = {};
|
||||
//var last_time_log = 0;
|
||||
|
||||
var drawtime_timeout;
|
||||
|
||||
// Date and time graphics buffers
|
||||
var dateColour = "#ffffff"; // override later
|
||||
var timeColour2 = timeColour;
|
||||
var g_d = Graphics.createArrayBuffer(g_width,g_height_d,1,{'msb':true});
|
||||
var g_t = Graphics.createArrayBuffer(g_width,g_height_t,1,{'msb':true});
|
||||
// Set screen mode and function to write graphics buffers
|
||||
|
@ -46,7 +49,7 @@ g.flip = function()
|
|||
height:g_height_d,
|
||||
buffer:g_d.buffer
|
||||
}, g_x_off, g_y_off + g_y_off_d);
|
||||
g.setColor(timeColour);
|
||||
g.setColor(timeColour2);
|
||||
g.drawImage(
|
||||
{
|
||||
width:g_width,
|
||||
|
@ -118,7 +121,7 @@ function formatDate(res,dateFormat){
|
|||
return(yyyy+"-"+m+"-"+w+"-"+d);
|
||||
}
|
||||
|
||||
function writeDozTime(text,def,colour){
|
||||
function writeDozTime(text,def){
|
||||
let pts = def.pts;
|
||||
let x=def.pt0[0];
|
||||
let y=def.pt0[1];
|
||||
|
@ -133,6 +136,7 @@ function writeDozTime(text,def,colour){
|
|||
}
|
||||
}
|
||||
function writeDozDate(text,def,colour){
|
||||
|
||||
dateColour = colour;
|
||||
let pts = def.pts;
|
||||
let x=def.pt0[0];
|
||||
|
@ -177,10 +181,10 @@ function drawTime()
|
|||
{
|
||||
// Write to background buffers, then display on screen
|
||||
writeDozDate(date,calenDef,res.colour);
|
||||
writeDozTime(time,timeDef,timeColour);
|
||||
writeDozTime(time,timeDef);
|
||||
g.flip();
|
||||
// Ready next interval
|
||||
setTimeout(drawTime,wait);
|
||||
drawtime_timeout = setTimeout(drawTime,wait);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -196,22 +200,14 @@ function modeTime()
|
|||
timeActiveUntil = new Date();
|
||||
timeActiveUntil.setDate(timeActiveUntil.getDate());
|
||||
timeActiveUntil.setSeconds(timeActiveUntil.getSeconds()+15);
|
||||
//Bangle.setLCDPower(true);
|
||||
clearTimeout();
|
||||
if (typeof drawtime_timeout !== 'undefined')
|
||||
{
|
||||
clearTimeout(drawtime_timeout);
|
||||
}
|
||||
drawTime();
|
||||
}
|
||||
|
||||
Bangle.loadWidgets();
|
||||
|
||||
// Time-logging function
|
||||
/*function logTime(label)
|
||||
{
|
||||
var d = new Date();
|
||||
var t = d.getTime();
|
||||
var diff_test = t - last_time_log;
|
||||
last_time_log = t;
|
||||
console.log(label + " at time: " + t + ", since last: " + diff_test);
|
||||
}*/
|
||||
Bangle.drawWidgets();
|
||||
|
||||
// Functions for weather mode - TODO
|
||||
function drawWeather() {}
|
||||
|
@ -222,4 +218,20 @@ Bangle.on('twist', function() {
|
|||
modeTime();
|
||||
});
|
||||
|
||||
Bangle.drawWidgets();
|
||||
// Time fix with GPS
|
||||
function fixTime() {
|
||||
Bangle.on("GPS",function cb(g) {
|
||||
Bangle.setGPSPower(0,"time");
|
||||
Bangle.removeListener("GPS",cb);
|
||||
if (!g.time || (g.time.getFullYear()<2000) ||
|
||||
(g.time.getFullYear()>2200)) {
|
||||
} else {
|
||||
// We have a GPS time. Set time
|
||||
setTime(g.time.getTime()/1000);
|
||||
}
|
||||
});
|
||||
Bangle.setGPSPower(1,"time");
|
||||
setTimeout(fixTime, 10*60*1000); // every 10 minutes
|
||||
}
|
||||
// Start time fixing with GPS on next 10 minute interval
|
||||
setTimeout(fixTime, ((60-(new Date()).getMinutes()) % 10) * 60 * 1000);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
0.01: Initial version
|
||||
0.02: Multiple pages
|
||||
0.03: cycle thru pages
|
||||
|
||||
0.04: reset to clock after 2 mins of inactivity
|
||||
|
|
|
@ -2,6 +2,20 @@
|
|||
*
|
||||
*/
|
||||
|
||||
function wdog(handle,timeout){
|
||||
if(handle !== undefined){
|
||||
wdog.handle = handle;
|
||||
wdog.timeout = timeout;
|
||||
}
|
||||
if(wdog.timer){
|
||||
clearTimeout(wdog.timer)
|
||||
}
|
||||
wdog.timer = setTimeout(wdog.handle,wdog.timeout)
|
||||
}
|
||||
|
||||
// reset after two minutes of inactivity
|
||||
wdog(load,120000)
|
||||
|
||||
var s = require("Storage");
|
||||
var apps = s.list(/\.info$/).map(app=>{var a=s.readJSON(app,1);return a&&{name:a.name,type:a.type,icon:a.icon,sortorder:a.sortorder,src:a.src};}).filter(app=>app && (app.type=="app" || app.type=="clock" || !app.type));
|
||||
apps.sort((a,b)=>{
|
||||
|
@ -42,6 +56,7 @@ function drawPage(p){
|
|||
}
|
||||
|
||||
Bangle.on("swipe",(dir)=>{
|
||||
wdog()
|
||||
selected = 0;
|
||||
oldselected=-1;
|
||||
if (dir<0){
|
||||
|
@ -54,6 +69,7 @@ Bangle.on("swipe",(dir)=>{
|
|||
});
|
||||
|
||||
function nextapp(d){
|
||||
wdog();
|
||||
oldselected = selected;
|
||||
selected+=d;
|
||||
selected = selected<0?5:selected>5?0:selected;
|
||||
|
|
|
@ -3,3 +3,4 @@
|
|||
0.04: Add functionality to sort apps manually or alphabetically ascending/descending.
|
||||
0.05: Tweaks to help with memory usage
|
||||
0.06: Reduce memory usage
|
||||
0.07: Allow negative numbers when manual-sorting
|
|
@ -180,7 +180,7 @@ function showSortAppsManually() {
|
|||
appList.reduce((menu, app) => {
|
||||
menu[app.name] = {
|
||||
value: app.sortorder || 0,
|
||||
min: 0,
|
||||
min: -appList.length,
|
||||
max: appList.length,
|
||||
step: 1,
|
||||
onchange: val => setSortorder(app, val)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
0.01: Cloning Magic 8 Ball and make it speak italian
|
|
@ -0,0 +1 @@
|
|||
require("heatshrink").decompress(atob("mEwhBC/AGMrq2B1gAEwNWlYthq2s64AKGYIydFpoAEGLUrFqIADqxcXFqhiDFymBFy7GCF1owTRjCSVlYudeiGsF7/XlaNqSKBeP1mBwJxQMBReO1gaEleBMDBLN1hAC1hhBAoIwNCwQAGlZINqxvFGAIXOSBAXQN4hPBC5yQIVBxfBCAgvQSBC+NFAYRDMwJHOF654DqxkBYooALF6+sbIhkEF8Z3CRIWBR6AvXFAzvQF6wnIYQJgNd5AWNdoLoGBBAvPO5pfYH4IvUUwS/GVBzXBYCpHCq2s1mBDwKOWDwRgNPAwVVMCRLCwIABCZ6OJJSAATLxZgRACJeLAAMrFz9WFxiRgRpoADwIub1guQGDmsXhqSfRiL0G1jqkMRYxRwKLUGK2sFryVEq2B1gAEwNWFkIA/AH4A/AH4AQ"))
|
|
@ -0,0 +1,79 @@
|
|||
const affirmative = [
|
||||
'È certo.',
|
||||
'È decisamente\ncosì.',
|
||||
'Senza alcun\ndubbio.',
|
||||
'Sì,\nsenza dubbio.',
|
||||
'Ci puoi\ncontare.',
|
||||
'Da quanto\nvedo,\nsì.',
|
||||
'Molto\nprobabilmente.',
|
||||
'Le prospettive\nsono buone.',
|
||||
'Sì.',
|
||||
'I segni\nindicano\ndi sì.'
|
||||
];
|
||||
const nonCommittal = [
|
||||
'È difficile\ndirlo,\nprova di nuovo.',
|
||||
'Rifai la domanda\npiù tardi.',
|
||||
'Meglio non\nrisponderti\nadesso.',
|
||||
'Non posso\npredirlo ora.',
|
||||
'Concentrati e\nrifai la\ndomanda.'
|
||||
];
|
||||
const negative = [
|
||||
'Non ci\ncontare.',
|
||||
'La mia\nrisposta\nè no.',
|
||||
'Le mie\nfonti dicono\ndi no.',
|
||||
'Le prospettive\nnon sono\nbuone.',
|
||||
'È molto\ndubbio.'
|
||||
];
|
||||
const title = 'Magic 8 Ball';
|
||||
|
||||
const answers = [affirmative, nonCommittal, negative];
|
||||
|
||||
function getRandomArbitrary(min, max) {
|
||||
return Math.random() * (max - min) + min;
|
||||
}
|
||||
|
||||
function predict() {
|
||||
// affirmative, negative or non-committal
|
||||
let max = answers.length;
|
||||
const a = Math.floor(getRandomArbitrary(0, max));
|
||||
// sets max compared to answer category
|
||||
max = answers[a].length;
|
||||
const b = Math.floor(getRandomArbitrary(0, max));
|
||||
// get the answer
|
||||
const response = answers[a][b];
|
||||
return response;
|
||||
}
|
||||
|
||||
function draw(msg) {
|
||||
// console.log(msg);
|
||||
g.clear();
|
||||
E.showMessage(msg, title);
|
||||
}
|
||||
|
||||
function reply(button) {
|
||||
const theButton = (typeof button === 'undefined' || isNaN(button)) ? 1 : button;
|
||||
const timer = Math.floor(getRandomArbitrary(0, theButton) * 1000);
|
||||
// Thinking...
|
||||
draw('...');
|
||||
setTimeout('draw(predict());', timer);
|
||||
}
|
||||
|
||||
function ask() {
|
||||
draw('Ponimi una\ndomanda\nSì/No e\ntocca lo\nschermo');
|
||||
}
|
||||
|
||||
g.clear();
|
||||
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
ask();
|
||||
|
||||
// Event Handlers
|
||||
|
||||
Bangle.on('touch', (button) => reply(button));
|
||||
|
||||
setWatch(ask, BTN1, { repeat: true, edge: "falling" });
|
||||
setWatch(reply, BTN3, { repeat: true, edge: "falling" });
|
||||
|
||||
// Back to launcher
|
||||
setWatch(Bangle.showLauncher, BTN2, { repeat: false, edge: "falling" });
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -0,0 +1 @@
|
|||
0.01: Cloning torch and making it red :D
|
|
@ -0,0 +1 @@
|
|||
require("heatshrink").decompress(atob("mEw4UA///oP4gH+t9TCQ1VAAYLpgILunoLK/4LJgf/6oLIh//+oLK/oLIhapBBZEqBYIwDBYu/GAgLE1WvGAgLF1YwEBQcC1WqGAgLGGAgLDhQLBGAdQBYwwCBQgLDGASlFlQLC3/8BYoIBGAXwBQkCFgILC4AuFBYeAFw2v/wLBBQqNCBYOgBQp1B1/qCw5dDFoxdEBQwuBAAOoBQykCHI4uXgZPBFxEP/QuJn5/CFw7DBLpILB9QuHEYP//QuHHYP//wuHKYL0HGAoLJn/8BZMP+ALJgfABRA="))
|
|
@ -0,0 +1,22 @@
|
|||
Bangle.setLCDPower(1);
|
||||
Bangle.setLCDTimeout(0);
|
||||
g.reset();
|
||||
c = 1;
|
||||
function setColor(delta){
|
||||
c+=delta;
|
||||
c = Math.max(c,0);
|
||||
c = Math.min(c,2);
|
||||
if (c<1){
|
||||
g.setColor(c,0,0);
|
||||
}else{
|
||||
g.setColor(1,c-1,c-1);
|
||||
}
|
||||
g.fillRect(0,0,g.getWidth(),g.getHeight());
|
||||
}
|
||||
setColor(0)
|
||||
// BTN1 light up toward white
|
||||
// BTN3 light down to red
|
||||
// BTN2 to reset
|
||||
setWatch(()=>setColor(0.1), BTN1, { repeat:true, edge:"rising", debounce: 50 });
|
||||
setWatch(()=>load(), BTN2);
|
||||
setWatch(()=>setColor(-0.1), BTN3, { repeat:true, edge:"rising", debounce: 50 });
|
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
|
@ -0,0 +1,26 @@
|
|||
(function() {
|
||||
var clickTimes = [];
|
||||
var clickPattern = "";
|
||||
var TAPS = 4; // number of taps
|
||||
var PERIOD = 1; // seconds
|
||||
|
||||
// we don't actually create/draw a widget here at all...
|
||||
Bangle.on("lcdPower",function(on) {
|
||||
// First click (that turns LCD on) isn't given to
|
||||
// setWatch, so handle it here
|
||||
if (!on) return;
|
||||
clickTimes=[getTime()];
|
||||
clickPattern="x";
|
||||
});
|
||||
function tap(e,c) {
|
||||
clickPattern = clickPattern.substr(-3)+c;
|
||||
while (clickTimes.length>=TAPS) clickTimes.shift();
|
||||
clickTimes.push(e.time);
|
||||
var clickPeriod = e.time-clickTimes[0];
|
||||
if (clickPeriod<PERIOD && clickPattern.match(/.131/)) {
|
||||
load("rtorch.app.js");
|
||||
}
|
||||
}
|
||||
setWatch(function(e) { tap(e,"1"); }, BTN1, {repeat:true, edge:"rising"});
|
||||
setWatch(function(e) { tap(e,"3"); }, BTN3, {repeat:true, edge:"rising"});
|
||||
})();
|
|
@ -0,0 +1 @@
|
|||
require("heatshrink").decompress(atob("mEwwhC/AH4AChGIxGAC6eIAQgARFgUIC9ReCAYJgSC7BHDF6gUBC6ovWI/5Hga/6P/ABsCkABDC/4XxkQXDkQuSAQwXPDQkAC6BBCkQDDC6MCmczFoIXQCQQXBDgQXP2EA2YXBncAhYXR3YXB3YXRCQWznYcCC6ICBAYYXPhYrBApAwPFyQqCIoYuRLwZgDAH4A/"))
|
|
@ -0,0 +1,28 @@
|
|||
function onTemperature(p) {
|
||||
g.reset(1).clearRect(0,24,g.getWidth(),g.getHeight());
|
||||
g.setFont("6x8",2).setFontAlign(0,0);
|
||||
var x = g.getWidth()/2;
|
||||
var y = g.getHeight()/2 + 10;
|
||||
g.drawString("Temperature", x, y - 45);
|
||||
g.setFontVector(70).setFontAlign(0,0);
|
||||
g.drawString(p.temperature.toFixed(1), x, y);
|
||||
}
|
||||
|
||||
function drawTemperature() {
|
||||
if (Bangle.getPressure) {
|
||||
Bangle.getPressure().then(onTemperature);
|
||||
} else {
|
||||
onTemperature({
|
||||
temperature : E.getTemperature() * (9/5) + 32
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setInterval(function() {
|
||||
drawTemperature();
|
||||
}, 20000);
|
||||
drawTemperature();
|
||||
E.showMessage("Loading...");
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Loading…
Reference in New Issue