Merge branch 'master' of github.com:espruino/BangleApps
commit
1d793a037f
24
apps.json
24
apps.json
|
|
@ -4425,7 +4425,7 @@
|
||||||
"name": "Q Alarm and Timer",
|
"name": "Q Alarm and Timer",
|
||||||
"shortName": "Q Alarm",
|
"shortName": "Q Alarm",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"version": "0.03",
|
"version": "0.04",
|
||||||
"description": "Alarm and timer app with days of week and 'hard' option.",
|
"description": "Alarm and timer app with days of week and 'hard' option.",
|
||||||
"tags": "tool,alarm,widget",
|
"tags": "tool,alarm,widget",
|
||||||
"supports": ["BANGLEJS", "BANGLEJS2"],
|
"supports": ["BANGLEJS", "BANGLEJS2"],
|
||||||
|
|
@ -5081,10 +5081,10 @@
|
||||||
{ "id": "circlesclock",
|
{ "id": "circlesclock",
|
||||||
"name": "Circles clock",
|
"name": "Circles clock",
|
||||||
"shortName":"Circles clock",
|
"shortName":"Circles clock",
|
||||||
"version":"0.03",
|
"version":"0.04",
|
||||||
"description": "A clock with circles for different data at the bottom in a probably familiar style",
|
"description": "A clock with circles for different data at the bottom in a probably familiar style",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"screenshots": [{"url":"screenshot.png"}],
|
"screenshots": [{"url":"screenshot-dark.png"}, {"url":"screenshot-light.png"}],
|
||||||
"dependencies": {"widpedom":"app"},
|
"dependencies": {"widpedom":"app"},
|
||||||
"type": "clock",
|
"type": "clock",
|
||||||
"tags": "clock",
|
"tags": "clock",
|
||||||
|
|
@ -5132,6 +5132,24 @@
|
||||||
{"name":"ltherm.img","url":"icon.js","evaluate":true}
|
{"name":"ltherm.img","url":"icon.js","evaluate":true}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "mmind",
|
||||||
|
"name": "Classic Mind Game",
|
||||||
|
"shortName":"Master Mind",
|
||||||
|
"icon": "mmind.png",
|
||||||
|
"version":"0.01",
|
||||||
|
"description": "This is the classic game for masterminds",
|
||||||
|
"screenshots": [{"url":"screenshot_mmind.png"}],
|
||||||
|
"type": "app",
|
||||||
|
"tags": "game",
|
||||||
|
"readme":"README.md",
|
||||||
|
"supports": ["BANGLEJS2"],
|
||||||
|
"allow_emulator": true,
|
||||||
|
"storage": [
|
||||||
|
{"name":"mmind.app.js","url":"mmind.app.js"},
|
||||||
|
{"name":"mmind.img","url":"mmind.icon.js","evaluate":true}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "presentor",
|
"id": "presentor",
|
||||||
"name": "Presentor",
|
"name": "Presentor",
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
0.01: New clock
|
0.01: New clock
|
||||||
0.02: Fix icon & add battery warn functionality
|
0.02: Fix icon & add battery warn functionality
|
||||||
0.03: Theming support & minor fixes
|
0.03: Theming support & minor fixes
|
||||||
|
0.04: Make configurable what to show in each circle
|
||||||
|
Add step distance and weather
|
||||||
|
Allow switching visibility of widgets
|
||||||
|
Make circles and text slightly bigger
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,22 @@
|
||||||
|
|
||||||
A clock with circles for different data at the bottom in a probably familiar style
|
A clock with circles for different data at the bottom in a probably familiar style
|
||||||
|
|
||||||
It shows besides time, date and day of week the following information:
|
By default the time, date and day of week is shown.
|
||||||
|
|
||||||
|
It can show the following information (this can be configured):
|
||||||
* Steps (requires [pedometer widget](https://banglejs.com/apps/#pedometer))
|
* Steps (requires [pedometer widget](https://banglejs.com/apps/#pedometer))
|
||||||
* Heart rate (when screen is on and unlocked)
|
* Steps distance (depending on steps)
|
||||||
* Battery (including charging and battery low)
|
* Heart rate (automatically updates when screen is on and unlocked)
|
||||||
|
* Battery (including charging status and battery low warning)
|
||||||
|
* Weather (requires [weather app](https://banglejs.com/apps/#weather))
|
||||||
|
|
||||||
## Screenshot
|
## Screenshots
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||

|
# TODO
|
||||||
|
* Add sunrise and sunset
|
||||||
## TODO
|
* Display moon instead of sun during night on weather circle
|
||||||
* Show weather information
|
|
||||||
* Configure which information to show in each circle
|
|
||||||
* Configure visibility of widgets
|
|
||||||
|
|
||||||
## Creator
|
## Creator
|
||||||
Marco ([myxor](https://github.com/myxor))
|
Marco ([myxor](https://github.com/myxor))
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,37 @@
|
||||||
const locale = require("locale");
|
const locale = require("locale");
|
||||||
const heatshrink = require("heatshrink");
|
const heatshrink = require("heatshrink");
|
||||||
|
const storage = require("Storage");
|
||||||
|
|
||||||
const shoesIcon = heatshrink.decompress(atob("h0OwYJGgmAAgUBkgECgVJB4cSoAUDyEBkARDpADBhMAyQRBgVAkgmDhIUDAAuQAgY1DAAYA="));
|
const shoesIcon = heatshrink.decompress(atob("h0OwYJGgmAAgUBkgECgVJB4cSoAUDyEBkARDpADBhMAyQRBgVAkgmDhIUDAAuQAgY1DAAYA="));
|
||||||
|
const shoesIconGreen = heatshrink.decompress(atob("h0OwYJGhIEDgVIAgUEyQKDkmACgcggVACIeQAYMSgIRCgmApIbDiQUDAAkBkAFDGoYAD"));
|
||||||
const heartIcon = heatshrink.decompress(atob("h0OwYOLkmQhMkgACByVJgESpIFBpEEBAIFBCgIFCCgsABwcAgQOCAAMSpAwDyBNM"));
|
const heartIcon = heatshrink.decompress(atob("h0OwYOLkmQhMkgACByVJgESpIFBpEEBAIFBCgIFCCgsABwcAgQOCAAMSpAwDyBNM"));
|
||||||
const powerIcon = heatshrink.decompress(atob("h0OwYQNsAED7AEDmwEDtu2AgUbtuABwXbBIUN23AAoYOCgEDFIgODABI"));
|
const powerIcon = heatshrink.decompress(atob("h0OwYQNsAED7AEDmwEDtu2AgUbtuABwXbBIUN23AAoYOCgEDFIgODABI"));
|
||||||
const powerIconGreen = heatshrink.decompress(atob("h0OwYQNkAEDpAEDiQEDkmSAgUJkmABwVJBIUEyVAAoYOCgEBFIgODABI"));
|
const powerIconGreen = heatshrink.decompress(atob("h0OwYQNkAEDpAEDiQEDkmSAgUJkmABwVJBIUEyVAAoYOCgEBFIgODABI"));
|
||||||
const powerIconRed = heatshrink.decompress(atob("h0OwYQNoAEDyAEDkgEDpIFDiVJBweSAgUJkmAAoYZDgQpEBwYAJA"));
|
const powerIconRed = heatshrink.decompress(atob("h0OwYQNoAEDyAEDkgEDpIFDiVJBweSAgUJkmAAoYZDgQpEBwYAJA"));
|
||||||
|
|
||||||
|
const weatherCloudy = heatshrink.decompress(atob("iEQwYWTgP//+AAoMPAoPwAoN/AocfAgP//0AAgQAB/AFEABgdDAAMDDohMRA"));
|
||||||
|
const weatherSunny = heatshrink.decompress(atob("iEQwYLIg3AAgVgAQMMAo8Am3YAgUB23bAoUNAoIUBjYFCsOwBYoFDDpFgHYI1JI4gFGAAYA="));
|
||||||
|
const weatherPartlyCloudy = heatshrink.decompress(atob("iEQwYQNv0AjgGDn4EDh///gFChwREC4MfxwIBv0//+AC4X4j4FCv/AgfwgED/wIBuAaBBwgFDgP4gf/AAXABwIEBDQQAEA=="));
|
||||||
|
const weatherRainy = heatshrink.decompress(atob("iEQwYLIg/gAgUB///wAFBh/AgfwgED/wIBuEAj4OCv0AjgaCh/4AocAnAFBFIU4EAM//gRBEAIOBhw1C/AmDAosAC4JNIAAg"));
|
||||||
|
const weatherPartlyRainy = heatshrink.decompress(atob("h0OwYJGjkAnAFCj+AAgU//4FCuEA8EAg8ch/4gEB4////AAoIIBCIMD/wgCg4bBg/8BwMD+AgBh4ZBDQf/FIIABh4IBgAA=="));
|
||||||
|
const weatherSnowy = heatshrink.decompress(atob("iEQwYROn/8AocH8AECuAFBh0Agf+CIN/4EDx/4j/x4EAgIIBwAXBAogRFDoopFGoxBGABIA="));
|
||||||
|
const weatherFoggy = heatshrink.decompress(atob("iEQwYROn/8AgUB/EfwAFBh/AgfwgED/wIBuEABwd/4EcDQgFDgE4Fosf///8f//A/Lj/xCQIRNA="));
|
||||||
|
const weatherStormy = heatshrink.decompress(atob("iEQwYLIg/gAgUB///wAFBh/AgfwgED/wIBuEAj4OCv0AjgaCh/4AoX8gE4AoQpBnAdBF4IRBDQMH/kOHgY7DAo4AOA=="));
|
||||||
|
|
||||||
let settings;
|
let settings;
|
||||||
|
|
||||||
function loadSettings() {
|
function loadSettings() {
|
||||||
settings = require("Storage").readJSON("circlesclock.json", 1) || {
|
settings = storage.readJSON("circlesclock.json", 1) || {
|
||||||
|
'minHR': 40,
|
||||||
'maxHR': 200,
|
'maxHR': 200,
|
||||||
'stepGoal': 10000,
|
'stepGoal': 10000,
|
||||||
'batteryWarn': 30
|
'stepDistanceGoal': 8000,
|
||||||
|
'stepLength': 0.8,
|
||||||
|
'batteryWarn': 30,
|
||||||
|
'showWidgets': false,
|
||||||
|
'circle1': 'hr',
|
||||||
|
'circle2': 'steps',
|
||||||
|
'circle3': 'battery'
|
||||||
};
|
};
|
||||||
// Load step goal from pedometer widget as fallback
|
// Load step goal from pedometer widget as fallback
|
||||||
if (settings.stepGoal == undefined) {
|
if (settings.stepGoal == undefined) {
|
||||||
|
|
@ -21,122 +39,227 @@ function loadSettings() {
|
||||||
settings.stepGoal = d != undefined && d.settings != undefined ? d.settings.goal : 10000;
|
settings.stepGoal = d != undefined && d.settings != undefined ? d.settings.goal : 10000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
loadSettings();
|
||||||
|
const showWidgets = settings.showWidgets || false;
|
||||||
|
|
||||||
|
let hrtValue;
|
||||||
|
|
||||||
|
// layout values:
|
||||||
const colorFg = g.theme.dark ? '#fff' : '#000';
|
const colorFg = g.theme.dark ? '#fff' : '#000';
|
||||||
const colorBg = g.theme.dark ? '#000' : '#fff';
|
const colorBg = g.theme.dark ? '#000' : '#fff';
|
||||||
const colorGrey = '#808080';
|
const colorGrey = '#808080';
|
||||||
const colorRed = '#ff0000';
|
const colorRed = '#ff0000';
|
||||||
const colorGreen = '#00ff00';
|
const colorGreen = '#008000';
|
||||||
|
const colorBlue = '#0000ff';
|
||||||
let hrtValue;
|
const colorYellow = '#ffff00';
|
||||||
|
const widgetOffset = showWidgets ? 24 : 0;
|
||||||
const h = g.getHeight();
|
const h = g.getHeight() - widgetOffset;
|
||||||
const w = g.getWidth();
|
const w = g.getWidth();
|
||||||
const hOffset = 30;
|
const hOffset = 30 - widgetOffset;
|
||||||
const h1 = Math.round(1 * h / 5 - hOffset);
|
const h1 = Math.round(1 * h / 5 - hOffset);
|
||||||
const h2 = Math.round(3 * h / 5 - hOffset);
|
const h2 = Math.round(3 * h / 5 - hOffset);
|
||||||
const h3 = Math.round(8 * h / 8 - hOffset);
|
const h3 = Math.round(8 * h / 8 - hOffset - 3); // circle y position
|
||||||
const w1 = Math.round(w / 6);
|
const circlePosX = [Math.round(w / 6), Math.round(3 * w / 6), Math.round(5 * w / 6)]; // cirle x positions
|
||||||
const w2 = Math.round(3 * w / 6);
|
const radiusOuter = 25;
|
||||||
const w3 = Math.round(5 * w / 6);
|
const radiusInner = 20;
|
||||||
const radiusOuter = 22;
|
const circleFont = "Vector:15";
|
||||||
const radiusInner = 16;
|
const circleFontBig = "Vector:16";
|
||||||
|
const circleFontSmall = "Vector:13";
|
||||||
|
|
||||||
function draw() {
|
function draw() {
|
||||||
g.reset();
|
g.clear(true);
|
||||||
|
|
||||||
|
if (!showWidgets) {
|
||||||
|
/*
|
||||||
|
* we are not drawing the widgets as we are taking over the whole screen
|
||||||
|
* so we will blank out the draw() functions of each widget and change the
|
||||||
|
* area to the top bar doesn't get cleared.
|
||||||
|
*/
|
||||||
|
if (WIDGETS && typeof WIDGETS === "object") {
|
||||||
|
for (let wd of WIDGETS) {
|
||||||
|
wd.draw = () => {};
|
||||||
|
wd.area = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Bangle.drawWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
g.setColor(colorBg);
|
g.setColor(colorBg);
|
||||||
g.fillRect(0, 0, w, h);
|
g.fillRect(0, widgetOffset, w, h);
|
||||||
|
|
||||||
// time
|
// time
|
||||||
g.setFont("Vector:50");
|
g.setFont("Vector:50");
|
||||||
g.setFontAlign(-1, -1);
|
g.setFontAlign(0, -1);
|
||||||
g.setColor(colorFg);
|
g.setColor(colorFg);
|
||||||
g.drawString(locale.time(new Date(), 1), w / 10, h1 + 8);
|
g.drawString(locale.time(new Date(), 1), w / 2, h1 + 8);
|
||||||
|
|
||||||
// date & dow
|
// date & dow
|
||||||
g.setFont("Vector:20");
|
g.setFont("Vector:21");
|
||||||
g.setFontAlign(-1, 0);
|
g.setFontAlign(-1, 0);
|
||||||
g.drawString(locale.date(new Date()), w / 10, h2);
|
g.drawString(locale.date(new Date()), w > 180 ? 2 * w / 10 : w / 10, h2);
|
||||||
g.drawString(locale.dow(new Date()), w / 10, h2 + 22);
|
g.drawString(locale.dow(new Date()), w > 180 ? 2 * w / 10 : w / 10, h2 + 22);
|
||||||
|
|
||||||
// Steps circle
|
drawCircle(1);
|
||||||
drawSteps();
|
drawCircle(2);
|
||||||
|
drawCircle(3);
|
||||||
// Heart circle
|
|
||||||
drawHeartRate();
|
|
||||||
|
|
||||||
// Battery circle
|
|
||||||
drawBattery();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const defaultCircleTypes = ["steps", "hr", "battery"];
|
||||||
|
|
||||||
|
function drawCircle(index) {
|
||||||
|
let type = settings['circle' + index];
|
||||||
|
if (!type) type = defaultCircleTypes[index - 1];
|
||||||
|
const w = getCirclePosition(type);
|
||||||
|
switch (type) {
|
||||||
|
case "steps":
|
||||||
|
drawSteps(w);
|
||||||
|
break;
|
||||||
|
case "stepsDist":
|
||||||
|
drawStepsDistance(w);
|
||||||
|
break;
|
||||||
|
case "hr":
|
||||||
|
drawHeartRate(w);
|
||||||
|
break;
|
||||||
|
case "battery":
|
||||||
|
drawBattery(w);
|
||||||
|
break;
|
||||||
|
case "weather":
|
||||||
|
drawWeather(w);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function drawSteps() {
|
function getCirclePosition(type) {
|
||||||
|
for (let i = 1; i <= 3; i++) {
|
||||||
|
const setting = settings['circle' + i];
|
||||||
|
if (setting == type) return circlePosX[i - 1];
|
||||||
|
}
|
||||||
|
for (let i = 0; i < defaultCircleTypes.length; i++) {
|
||||||
|
if (type == defaultCircleTypes[i]) return circlePosX[i];
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isCircleEnabled(type) {
|
||||||
|
return getCirclePosition(type) != undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawSteps(w) {
|
||||||
|
if (!w) w = getCirclePosition("steps");
|
||||||
const steps = getSteps();
|
const steps = getSteps();
|
||||||
const blue = '#0000ff';
|
|
||||||
|
// Draw rectangle background:
|
||||||
|
g.setColor(colorBg);
|
||||||
|
g.fillRect(w - radiusOuter - 3, h3 - radiusOuter - 3, w + radiusOuter + 3, h3 + radiusOuter + 3);
|
||||||
|
|
||||||
g.setColor(colorGrey);
|
g.setColor(colorGrey);
|
||||||
g.fillCircle(w1, h3, radiusOuter);
|
g.fillCircle(w, h3, radiusOuter);
|
||||||
|
|
||||||
const stepGoal = settings.stepGoal || 10000;
|
const stepGoal = settings.stepGoal || 10000;
|
||||||
if (stepGoal > 0) {
|
if (stepGoal > 0) {
|
||||||
let percent = steps / stepGoal;
|
let percent = steps / stepGoal;
|
||||||
if (stepGoal < steps) percent = 1;
|
if (stepGoal < steps) percent = 1;
|
||||||
drawGauge(w1, h3, percent, blue);
|
drawGauge(w, h3, percent, colorBlue);
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setColor(colorBg);
|
g.setColor(colorBg);
|
||||||
g.fillCircle(w1, h3, radiusInner);
|
g.fillCircle(w, h3, radiusInner);
|
||||||
|
|
||||||
g.fillPoly([w1, h3, w1 - 15, h3 + radiusOuter + 5, w1 + 15, h3 + radiusOuter + 5]);
|
g.fillPoly([w, h3, w - 15, h3 + radiusOuter + 5, w + 15, h3 + radiusOuter + 5]);
|
||||||
|
|
||||||
g.setFont("Vector:12");
|
g.setFont(circleFont);
|
||||||
g.setFontAlign(0, 0);
|
g.setFontAlign(0, 0);
|
||||||
g.setColor(colorFg);
|
g.setColor(colorFg);
|
||||||
g.drawString(shortValue(steps), w1 + 2, h3);
|
g.drawString(shortValue(steps), w + 2, h3);
|
||||||
|
|
||||||
g.drawImage(shoesIcon, w1 - 6, h3 + radiusOuter - 6);
|
g.drawImage(shoesIcon, w - 6, h3 + radiusOuter - 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawHeartRate() {
|
function drawStepsDistance(w) {
|
||||||
|
if (!w) w = getCirclePosition("steps");
|
||||||
|
const steps = getSteps();
|
||||||
|
const stepDistance = settings.stepLength || 0.8;
|
||||||
|
const stepsDistance = Math.round(steps * stepDistance);
|
||||||
|
|
||||||
|
// Draw rectangle background:
|
||||||
|
g.setColor(colorBg);
|
||||||
|
g.fillRect(w - radiusOuter - 3, h3 - radiusOuter - 3, w + radiusOuter + 3, h3 + radiusOuter + 3);
|
||||||
|
|
||||||
g.setColor(colorGrey);
|
g.setColor(colorGrey);
|
||||||
g.fillCircle(w2, h3, radiusOuter);
|
g.fillCircle(w, h3, radiusOuter);
|
||||||
|
|
||||||
|
const stepDistanceGoal = settings.stepDistanceGoal || 8000;
|
||||||
|
if (stepDistanceGoal > 0) {
|
||||||
|
let percent = stepsDistance / stepDistanceGoal;
|
||||||
|
if (stepDistanceGoal < stepsDistance) percent = 1;
|
||||||
|
drawGauge(w, h3, percent, colorGreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
g.setColor(colorBg);
|
||||||
|
g.fillCircle(w, h3, radiusInner);
|
||||||
|
|
||||||
|
g.fillPoly([w, h3, w - 15, h3 + radiusOuter + 5, w + 15, h3 + radiusOuter + 5]);
|
||||||
|
|
||||||
|
g.setFont(circleFont);
|
||||||
|
g.setFontAlign(0, 0);
|
||||||
|
g.setColor(colorFg);
|
||||||
|
g.drawString(shortValue(stepsDistance), w + 2, h3);
|
||||||
|
|
||||||
|
g.drawImage(shoesIconGreen, w - 6, h3 + radiusOuter - 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawHeartRate(w) {
|
||||||
|
if (!w) w = getCirclePosition("hr");
|
||||||
|
|
||||||
|
// Draw rectangle background:
|
||||||
|
g.setColor(colorBg);
|
||||||
|
g.fillRect(w - radiusOuter - 3, h3 - radiusOuter - 3, w + radiusOuter + 3, h3 + radiusOuter + 3);
|
||||||
|
|
||||||
|
g.setColor(colorGrey);
|
||||||
|
g.fillCircle(w, h3, radiusOuter);
|
||||||
|
|
||||||
if (hrtValue != undefined && hrtValue > 0) {
|
if (hrtValue != undefined && hrtValue > 0) {
|
||||||
const minHR = 40;
|
const minHR = settings.minHR || 40;
|
||||||
const percent = (hrtValue - minHR) / (settings.maxHR - minHR);
|
const percent = (hrtValue - minHR) / (settings.maxHR - minHR);
|
||||||
drawGauge(w2, h3, percent, colorRed);
|
drawGauge(w, h3, percent, colorRed);
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setColor(colorBg);
|
g.setColor(colorBg);
|
||||||
g.fillCircle(w2, h3, radiusInner);
|
g.fillCircle(w, h3, radiusInner);
|
||||||
|
|
||||||
g.fillPoly([w2, h3, w2 - 15, h3 + radiusOuter + 5, w2 + 15, h3 + radiusOuter + 5]);
|
g.fillPoly([w, h3, w - 15, h3 + radiusOuter + 5, w + 15, h3 + radiusOuter + 5]);
|
||||||
|
|
||||||
g.setFont("Vector:12");
|
g.setFont(circleFontBig);
|
||||||
g.setFontAlign(0, 0);
|
g.setFontAlign(0, 0);
|
||||||
g.setColor(colorFg);
|
g.setColor(colorFg);
|
||||||
g.drawString(hrtValue != undefined ? hrtValue : "-", w2, h3);
|
g.drawString(hrtValue != undefined ? hrtValue : "-", w, h3);
|
||||||
|
|
||||||
g.drawImage(heartIcon, w2 - 6, h3 + radiusOuter - 6);
|
g.drawImage(heartIcon, w - 6, h3 + radiusOuter - 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawBattery() {
|
function drawBattery(w) {
|
||||||
|
if (!w) w = getCirclePosition("battery");
|
||||||
const battery = E.getBattery();
|
const battery = E.getBattery();
|
||||||
const yellow = '#ffff00';
|
|
||||||
|
// Draw rectangle background:
|
||||||
|
g.setColor(colorBg);
|
||||||
|
g.fillRect(w - radiusOuter - 3, h3 - radiusOuter - 3, w + radiusOuter + 3, h3 + radiusOuter + 3);
|
||||||
|
|
||||||
g.setColor(colorGrey);
|
g.setColor(colorGrey);
|
||||||
g.fillCircle(w3, h3, radiusOuter);
|
g.fillCircle(w, h3, radiusOuter);
|
||||||
|
|
||||||
if (battery > 0) {
|
if (battery > 0) {
|
||||||
const percent = battery / 100;
|
const percent = battery / 100;
|
||||||
drawGauge(w3, h3, percent, yellow);
|
drawGauge(w, h3, percent, colorYellow);
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setColor(colorBg);
|
g.setColor(colorBg);
|
||||||
g.fillCircle(w3, h3, radiusInner);
|
g.fillCircle(w, h3, radiusInner);
|
||||||
|
|
||||||
g.fillPoly([w3, h3, w3 - 15, h3 + radiusOuter + 5, w3 + 15, h3 + radiusOuter + 5]);
|
g.fillPoly([w, h3, w - 15, h3 + radiusOuter + 5, w + 15, h3 + radiusOuter + 5]);
|
||||||
|
|
||||||
g.setFont("Vector:12");
|
g.setFont(circleFont);
|
||||||
g.setFontAlign(0, 0);
|
g.setFontAlign(0, 0);
|
||||||
|
|
||||||
let icon = powerIcon;
|
let icon = powerIcon;
|
||||||
|
|
@ -144,17 +267,95 @@ function drawBattery() {
|
||||||
if (Bangle.isCharging()) {
|
if (Bangle.isCharging()) {
|
||||||
color = colorGreen;
|
color = colorGreen;
|
||||||
icon = powerIconGreen;
|
icon = powerIconGreen;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (settings.batteryWarn != undefined && battery <= settings.batteryWarn) {
|
if (settings.batteryWarn != undefined && battery <= settings.batteryWarn) {
|
||||||
color = colorRed;
|
color = colorRed;
|
||||||
icon = powerIconRed;
|
icon = powerIconRed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g.setColor(color);
|
g.setColor(color);
|
||||||
g.drawString(battery + '%', w3, h3);
|
g.drawString(battery + '%', w, h3);
|
||||||
|
|
||||||
g.drawImage(icon, w3 - 6, h3 + radiusOuter - 6);
|
g.drawImage(icon, w - 6, h3 + radiusOuter - 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawWeather(w) {
|
||||||
|
if (!w) w = getCirclePosition("weather");
|
||||||
|
const weather = getWeather();
|
||||||
|
const tempString = weather ? locale.temp(weather.temp - 273.15) : undefined;
|
||||||
|
const code = weather ? weather.code : -1;
|
||||||
|
|
||||||
|
// Draw rectangle background:
|
||||||
|
g.setColor(colorBg);
|
||||||
|
g.fillRect(w - radiusOuter - 3, h3 - radiusOuter - 3, w + radiusOuter + 3, h3 + radiusOuter + 3);
|
||||||
|
|
||||||
|
g.setColor(colorGrey);
|
||||||
|
g.fillCircle(w, h3, radiusOuter);
|
||||||
|
|
||||||
|
g.setColor(colorBg);
|
||||||
|
g.fillCircle(w, h3, radiusInner);
|
||||||
|
|
||||||
|
g.fillPoly([w, h3, w - 25, h3 + radiusOuter + 5, w + 25, h3 + radiusOuter + 5]);
|
||||||
|
|
||||||
|
const content = tempString ? tempString : "?";
|
||||||
|
g.setFont(content.length < 4 ? circleFont : circleFontSmall);
|
||||||
|
g.setFontAlign(0, 0);
|
||||||
|
g.setColor(colorFg);
|
||||||
|
g.drawString(content, w, h3);
|
||||||
|
|
||||||
|
if (code > 0) {
|
||||||
|
const icon = getWeatherIconByCode(code);
|
||||||
|
if (icon) g.drawImage(icon, w - 6, h3 + radiusOuter - 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Choose weather icon to display based on weather conditition code
|
||||||
|
* https://openweathermap.org/weather-conditions#Weather-Condition-Codes-2
|
||||||
|
*/
|
||||||
|
function getWeatherIconByCode(code) {
|
||||||
|
const codeGroup = Math.round(code / 100);
|
||||||
|
switch (codeGroup) {
|
||||||
|
case 2:
|
||||||
|
return weatherStormy;
|
||||||
|
case 3:
|
||||||
|
return weatherCloudy;
|
||||||
|
case 5:
|
||||||
|
switch (code) {
|
||||||
|
case 511:
|
||||||
|
return weatherSnowy;
|
||||||
|
case 520:
|
||||||
|
return weatherPartlyRainy;
|
||||||
|
case 521:
|
||||||
|
return weatherPartlyRainy;
|
||||||
|
case 522:
|
||||||
|
return weatherPartlyRainy;
|
||||||
|
case 531:
|
||||||
|
return weatherPartlyRainy;
|
||||||
|
default:
|
||||||
|
return weatherRainy;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
return weatherSnowy;
|
||||||
|
case 7:
|
||||||
|
return weatherFoggy;
|
||||||
|
case 8:
|
||||||
|
switch (code) {
|
||||||
|
case 800:
|
||||||
|
return weatherSunny;
|
||||||
|
case 801:
|
||||||
|
return weatherPartlyCloudy;
|
||||||
|
case 802:
|
||||||
|
return weatherPartlyCloudy;
|
||||||
|
default:
|
||||||
|
return weatherCloudy;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function radians(a) {
|
function radians(a) {
|
||||||
|
|
@ -171,11 +372,11 @@ function drawGauge(cx, cy, percent, color) {
|
||||||
if (percent > 1) percent = 1;
|
if (percent > 1) percent = 1;
|
||||||
|
|
||||||
var startrot = -offset;
|
var startrot = -offset;
|
||||||
var endrot = startrot - ((end - offset) * percent) - 15;
|
var endrot = startrot - ((end - offset) * percent) - 35;
|
||||||
|
|
||||||
g.setColor(color);
|
g.setColor(color);
|
||||||
|
|
||||||
const size = 4;
|
const size = radiusOuter - radiusInner - 2;
|
||||||
// draw gauge
|
// draw gauge
|
||||||
for (i = startrot; i > endrot - size; i -= size) {
|
for (i = startrot; i > endrot - size; i -= size) {
|
||||||
x = cx + r * Math.sin(radians(i));
|
x = cx + r * Math.sin(radians(i));
|
||||||
|
|
@ -198,54 +399,56 @@ function shortValue(v) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSteps() {
|
function getSteps() {
|
||||||
if (WIDGETS.wpedom !== undefined) {
|
if (WIDGETS && WIDGETS.wpedom !== undefined) {
|
||||||
return WIDGETS.wpedom.getSteps();
|
return WIDGETS.wpedom.getSteps();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bangle.on('lock', function(isLocked) {
|
function getWeather() {
|
||||||
if (!isLocked) {
|
const jsonWeather = storage.readJSON('weather.json');
|
||||||
Bangle.setHRMPower(1, "watch");
|
return jsonWeather && jsonWeather.weather ? jsonWeather.weather : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function enableHRMSensor() {
|
||||||
|
Bangle.setHRMPower(1, "circleclock");
|
||||||
if (hrtValue == undefined) {
|
if (hrtValue == undefined) {
|
||||||
hrtValue = '...';
|
hrtValue = '...';
|
||||||
drawHeartRate();
|
drawHeartRate();
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
Bangle.setHRMPower(0, "watch");
|
|
||||||
|
Bangle.on('lock', function(isLocked) {
|
||||||
|
if (!isLocked) {
|
||||||
|
if (isCircleEnabled("hr")) {
|
||||||
|
enableHRMSensor();
|
||||||
|
}
|
||||||
|
draw();
|
||||||
|
} else {
|
||||||
|
Bangle.setHRMPower(0, "circleclock");
|
||||||
}
|
}
|
||||||
drawHeartRate();
|
|
||||||
drawSteps();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Bangle.on('HRM', function(hrm) {
|
Bangle.on('HRM', function(hrm) {
|
||||||
//if(hrm.confidence > 90){
|
if (isCircleEnabled("hr")) {
|
||||||
hrtValue = hrm.bpm;
|
hrtValue = hrm.bpm;
|
||||||
if (Bangle.isLCDOn())
|
if (Bangle.isLCDOn())
|
||||||
drawHeartRate();
|
drawHeartRate();
|
||||||
//} else {
|
}
|
||||||
// hrtValue = undefined;
|
|
||||||
//}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Bangle.setUI("clock");
|
||||||
|
Bangle.loadWidgets();
|
||||||
|
|
||||||
|
draw();
|
||||||
|
setInterval(draw, 60000);
|
||||||
|
|
||||||
Bangle.on('charging', function(charging) {
|
Bangle.on('charging', function(charging) {
|
||||||
drawBattery();
|
if (isCircleEnabled("battery")) drawBattery();
|
||||||
});
|
});
|
||||||
|
|
||||||
g.clear();
|
if (isCircleEnabled("hr")) {
|
||||||
Bangle.loadWidgets();
|
enableHRMSensor();
|
||||||
/*
|
|
||||||
* we are not drawing the widgets as we are taking over the whole screen
|
|
||||||
* so we will blank out the draw() functions of each widget and change the
|
|
||||||
* area to the top bar doesn't get cleared.
|
|
||||||
*/
|
|
||||||
if (typeof WIDGETS === "object") {
|
|
||||||
for (let wd of WIDGETS) {
|
|
||||||
wd.draw = () => {};
|
|
||||||
wd.area = "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
loadSettings();
|
|
||||||
setInterval(draw, 60000);
|
|
||||||
draw();
|
|
||||||
Bangle.setUI("clock");
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.5 KiB |
|
|
@ -6,13 +6,26 @@
|
||||||
settings[key] = value;
|
settings[key] = value;
|
||||||
storage.write(SETTINGS_FILE, settings);
|
storage.write(SETTINGS_FILE, settings);
|
||||||
}
|
}
|
||||||
|
var valuesCircleTypes = ["steps", "stepsDist", "hr", "battery", "weather"];
|
||||||
|
var namesCircleTypes = ["steps", "distance", "heart", "battery", "weather"];
|
||||||
E.showMenu({
|
E.showMenu({
|
||||||
'': { 'title': 'circlesclock' },
|
'': { 'title': 'circlesclock' },
|
||||||
|
'< Back': back,
|
||||||
|
'min heartrate': {
|
||||||
|
value: "minHR" in settings ? settings.minHR : 40,
|
||||||
|
min: 0,
|
||||||
|
max : 250,
|
||||||
|
step: 5,
|
||||||
|
format: x => {
|
||||||
|
return x;
|
||||||
|
},
|
||||||
|
onchange: x => save('minHR', x),
|
||||||
|
},
|
||||||
'max heartrate': {
|
'max heartrate': {
|
||||||
value: "maxHR" in settings ? settings.maxHR : 200,
|
value: "maxHR" in settings ? settings.maxHR : 200,
|
||||||
min: 20,
|
min: 20,
|
||||||
max : 250,
|
max : 250,
|
||||||
step: 10,
|
step: 5,
|
||||||
format: x => {
|
format: x => {
|
||||||
return x;
|
return x;
|
||||||
},
|
},
|
||||||
|
|
@ -28,7 +41,27 @@
|
||||||
},
|
},
|
||||||
onchange: x => save('stepGoal', x),
|
onchange: x => save('stepGoal', x),
|
||||||
},
|
},
|
||||||
'battery warn lvl': {
|
'step length': {
|
||||||
|
value: "stepLength" in settings ? settings.stepLength : 0.8,
|
||||||
|
min: 0.1,
|
||||||
|
max : 1.5,
|
||||||
|
step: 0.01,
|
||||||
|
format: x => {
|
||||||
|
return x;
|
||||||
|
},
|
||||||
|
onchange: x => save('stepLength', x),
|
||||||
|
},
|
||||||
|
'step dist goal': {
|
||||||
|
value: "stepDistanceGoal" in settings ? settings.stepDistanceGoal : 8000,
|
||||||
|
min: 2000,
|
||||||
|
max : 30000,
|
||||||
|
step: 1000,
|
||||||
|
format: x => {
|
||||||
|
return x;
|
||||||
|
},
|
||||||
|
onchange: x => save('stepDistanceGoal', x),
|
||||||
|
},
|
||||||
|
'battery warn': {
|
||||||
value: "batteryWarn" in settings ? settings.batteryWarn : 30,
|
value: "batteryWarn" in settings ? settings.batteryWarn : 30,
|
||||||
min: 10,
|
min: 10,
|
||||||
max : 100,
|
max : 100,
|
||||||
|
|
@ -38,6 +71,28 @@
|
||||||
},
|
},
|
||||||
onchange: x => save('batteryWarn', x),
|
onchange: x => save('batteryWarn', x),
|
||||||
},
|
},
|
||||||
'< Back': back,
|
'show widgets': {
|
||||||
|
value: "showWidgets" in settings ? settings.showWidgets : false,
|
||||||
|
format: () => (settings.showWidgets ? 'Yes' : 'No'),
|
||||||
|
onchange: x => save('showWidgets', x),
|
||||||
|
},
|
||||||
|
'left': {
|
||||||
|
value: settings.circle1 ? valuesCircleTypes.indexOf(settings.circle1) : 0,
|
||||||
|
min: 0, max: 4,
|
||||||
|
format: v => namesCircleTypes[v],
|
||||||
|
onchange: x => save('circle1', valuesCircleTypes[x]),
|
||||||
|
},
|
||||||
|
'middle': {
|
||||||
|
value: settings.circle2 ? valuesCircleTypes.indexOf(settings.circle2) : 2,
|
||||||
|
min: 0, max: 4,
|
||||||
|
format: v => namesCircleTypes[v],
|
||||||
|
onchange: x => save('circle2', valuesCircleTypes[x]),
|
||||||
|
},
|
||||||
|
'right': {
|
||||||
|
value: settings.circle3 ? valuesCircleTypes.indexOf(settings.circle3) : 3,
|
||||||
|
min: 0, max: 4,
|
||||||
|
format: v => namesCircleTypes[v],
|
||||||
|
onchange: x => save('circle3', valuesCircleTypes[x]),
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
0.01: First release
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
# Mastermind
|
||||||
|
|
||||||
|
Play the classic mind game mastermind on your Bangle 2.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
## Game
|
||||||
|
The game will start when run.
|
||||||
|
Four colors pins are randomly chosen and kept secret.
|
||||||
|
You need to find the secret by scoring your choice within 6 turns.
|
||||||
|
The game makes use of touch features.
|
||||||
|
|
||||||
|
|
||||||
|
## Play
|
||||||
|
Select one of the dots, the color menu will show, select a colour for the pin.
|
||||||
|
If all pins are chosen with a color the red button will turn green.
|
||||||
|
Hit the green button and your play will be scored and listed from the top.
|
||||||
|
The first digit shows the number of pins with the correct color and in the right place.
|
||||||
|
The second digit gives the number of pins with the correct color but in the wrong place.
|
||||||
|
There are six turns to get the correct secret.
|
||||||
|
The blue button will start a new game.
|
||||||
|
|
||||||
|
|
||||||
|
## Requests
|
||||||
|
This is the first version, things to add are:
|
||||||
|
Add a menu to change game options like the number of colors, allow double colors, 5 pins per row. Add feature to drag screen up and down to see more scores. Timer and high score.
|
||||||
|
Any other fearures or remarks, let me know @psbest.
|
||||||
|
|
||||||
|
## Creator
|
||||||
|
This game is created by Peter Slendebroek.
|
||||||
|
|
@ -0,0 +1,198 @@
|
||||||
|
//MMind
|
||||||
|
|
||||||
|
//set vars
|
||||||
|
const H = g.getWidth();
|
||||||
|
const W = g.getHeight();
|
||||||
|
var touch_actions = [];
|
||||||
|
var cols = ["#FF0000","#00FF00","#0000FF", "#FF00FF", "#FFFF00", "#00FFFF", "#000000","#FFFFFF"];
|
||||||
|
var turn = 0;
|
||||||
|
var col_menu = false;
|
||||||
|
//pinsRow = 6;
|
||||||
|
//pinsThick = 10;
|
||||||
|
//pinsRow = 5;
|
||||||
|
//pinsThick = 10;
|
||||||
|
var pinsRow = 4;
|
||||||
|
var pinsThick = 10;
|
||||||
|
var play = [-1, -1, -1, -1];
|
||||||
|
|
||||||
|
var pinsCol = 5;
|
||||||
|
var playx = -1;
|
||||||
|
var sx = (W - 30 )/pinsRow;
|
||||||
|
var sy = (H - 20 )/7;
|
||||||
|
var touch_actions = [];
|
||||||
|
var secret = [];
|
||||||
|
var secret_no_dub = true;
|
||||||
|
var endgame = false;
|
||||||
|
|
||||||
|
g.clear();
|
||||||
|
g.setColor("#FFFFFF");
|
||||||
|
g.fillRect(0, 0, H, W);
|
||||||
|
g.setFont("Vector12",45);
|
||||||
|
|
||||||
|
function draw() {
|
||||||
|
touch_actions = [];
|
||||||
|
g.clear();
|
||||||
|
g.setColor("#FFFFFF");
|
||||||
|
g.fillRect(0, 0, H, W);
|
||||||
|
g.setColor("#000000");
|
||||||
|
//draw scores
|
||||||
|
for (y=0;y<game.length;y+=1) {
|
||||||
|
pp = game[y][0];
|
||||||
|
ps = game[y][1];
|
||||||
|
g.setColor("#000000");
|
||||||
|
//g.fillRect(W-30,10, W-30, 15);
|
||||||
|
g.setColor("#000000");
|
||||||
|
g.setFont("Vector30",10);
|
||||||
|
g.drawString(ps[0],W-31,y*sy+8);
|
||||||
|
g.setColor("#000000");
|
||||||
|
g.drawString(ps[1],W-15,y*sy+8);
|
||||||
|
g.setColor("#000000");
|
||||||
|
for (x=0;x<pinsRow;x+=1) {
|
||||||
|
xx = sx*x + pinsThick + 5;
|
||||||
|
yy = sy*y+20;
|
||||||
|
xc = pp[x];
|
||||||
|
g.setColor(cols[xc]);
|
||||||
|
g.fillCircle(xx,yy , pinsThick );
|
||||||
|
g.setColor("#000000");
|
||||||
|
g.drawCircle(xx,yy,pinsThick+1);
|
||||||
|
g.drawCircle(xx,yy,pinsThick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//draw play input
|
||||||
|
for (k=0; k<pinsRow; k+=1){
|
||||||
|
xx = sx*k + pinsThick + 5;
|
||||||
|
yy = sy*7;
|
||||||
|
touch_actions.push([[xx-pinsThick-5, yy-pinsThick-10, xx+pinsThick+5, yy+pinsThick+20],[1,k]]);
|
||||||
|
if (play[k] < 0) {
|
||||||
|
//col not choisen, draw small dot
|
||||||
|
g.setColor("#000000");
|
||||||
|
g.fillCircle(xx,yy , 3 );
|
||||||
|
} else {
|
||||||
|
g.setColor(cols[play[k]]);
|
||||||
|
g.fillCircle(xx,yy , pinsThick );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// draw action button
|
||||||
|
// score, men
|
||||||
|
if (!endgame) {
|
||||||
|
if (col_menu) {
|
||||||
|
draw_col_choice();
|
||||||
|
} else {
|
||||||
|
// check if all pins are set yet
|
||||||
|
if (Math.min.apply(null,play) < 0) {
|
||||||
|
g.setColor("#FF0000");
|
||||||
|
} else {
|
||||||
|
g.setColor("#00FF00");
|
||||||
|
touch_actions.push([[W-30, H-30,192, 190], [3,1]]);
|
||||||
|
}
|
||||||
|
g.fillRect(W-30, H-30, W-1, H-10);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
g.setColor("#0000FF");
|
||||||
|
touch_actions.push([[W-30, H-30,192, 190], [4,1]]);
|
||||||
|
g.fillRect(W-30, H-30, W-1, H-10);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_secret() {
|
||||||
|
//secret=[];
|
||||||
|
for (i=0; i<pinsRow; i+=1) {
|
||||||
|
s = Math.round(Math.random()*pinsCol);
|
||||||
|
if (secret_no_dub)
|
||||||
|
while(secret.indexOf(s) >= 0) s = Math.round(Math.random()*pinsCol);
|
||||||
|
secret[i]= s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function score() {
|
||||||
|
bScore = 0;
|
||||||
|
wScore = 0;
|
||||||
|
for (i=0; i<pinsRow; i+=1) {
|
||||||
|
if (secret[i] == play[i]) {
|
||||||
|
bScore +=1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (s=0; s<pinsRow; s+=1) {
|
||||||
|
if (secret[i] == play[s]) {
|
||||||
|
wScore +=1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return([bScore, wScore]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw_col_choice(){
|
||||||
|
var cc = g.getColor();
|
||||||
|
var boxw = 30;
|
||||||
|
var boxh = H/pinsRow-20;
|
||||||
|
for (i=0; i<=pinsCol; i+=1) {
|
||||||
|
g.setColor(cols[i]);
|
||||||
|
g.fillRect(W-boxw, i*boxh, W-1, i*boxh+boxh);
|
||||||
|
touch_actions.push([[150, i*boxh, 191, i*boxh+boxh], [2,i]]);
|
||||||
|
g.setColor(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Bangle.on('touch', function(zone,e) {
|
||||||
|
//console.log(e.x, e.y);
|
||||||
|
// check touch actions array to see what to do
|
||||||
|
for(i=0; i<touch_actions.length; i+=1) {
|
||||||
|
if (e.x > touch_actions[i][0][0] && e.x < touch_actions[i][0][2] &&
|
||||||
|
e.y > touch_actions[i][0][1] && e.y < touch_actions[i][0][3]) {
|
||||||
|
// a action is hit, add acctions here, todo: start, stop, new, etc.
|
||||||
|
switch (touch_actions[i][1][0]) {
|
||||||
|
case 1:
|
||||||
|
//get pins col menu
|
||||||
|
col_menu = 1;
|
||||||
|
playx = touch_actions[i][1][1];
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
//copy choice col to play
|
||||||
|
play[playx] = touch_actions[i][1][1];
|
||||||
|
col_menu = 0;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
//score play
|
||||||
|
var sc;
|
||||||
|
sc = score();
|
||||||
|
game.push([play, sc]);
|
||||||
|
play = [-1,-1,-1,-1];
|
||||||
|
turn+=1;
|
||||||
|
if (turn==6 || sc[0]==pinsRow) {
|
||||||
|
play = secret;
|
||||||
|
col_menu = 0;
|
||||||
|
endgame = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
//new game
|
||||||
|
play = [-1,-1,-1,-1];
|
||||||
|
game = [];
|
||||||
|
endgame=false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//console.log(touch_actions[i][1][0], touch_actions[i][1][1]);
|
||||||
|
|
||||||
|
draw();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
game = [];
|
||||||
|
get_secret();
|
||||||
|
draw();
|
||||||
|
//Bangle.loadWidgets();
|
||||||
|
//Bangle.drawWidgets();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
require("heatshrink").decompress(atob("mEwxH+64A/AEOBq2sBAusqwJHCaQFDAYlP2m0yGBCIkSj0eiWHBIkDgsFgYTE01v3O5t4mC1krgAEBq0ACYQuCAANsHIcxFwIwCEocsFwIwCBIYuCAANQF4QwBOgQABAgNIF4ZgELwQvCHIcCF4cEKwYvEt45DF4QwCL5YvFL5ITDF6OstheCvTjEjAuBjDJFX4UEq4TEyguBygTEF4dWBIeskkkqwQDDgUGgwaEBIUBgITHkslCYeBd4MrqwDBAgIuBcwRVGNIVs0oJEv3S6V+CYmIisjkcVZAYpBgDyBAAJFBFwTlGZIolDqouBGAQJDFwQABmRfCFAICCGwXXhgvDMAheCfI1UF4eoKwYvEiovHSoJfLF4pfJCYYvN1gwBAYMSLwVcbQmQFwOQZIq/C1GACYkcFwMcCYQoCLYNWF4KPBDgNWmIkEBIVPp5TDBIdWqoTHmUyCYlWRQTwCD4wA/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AH4A/AHmy2QJH6PRBI/Q6AkOCAIAFBINDjwABGInR3+53O/GIu72gABGJnQCAQAE69oFwQABCYfFFwIwCBIfCDIe7FIus1gvXLwQACLw4aCAAkAgAvcL4gvLq1WF5uyFwdoCYfLF4fLDpHCX6owBtFoxoUF6PF4ruFDwPC4XJFxbSCAAwVNAH4ARA"))
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"id": "mmind",
|
||||||
|
"name": "Classic Mind Game",
|
||||||
|
"shortName":"Master Mind",
|
||||||
|
"icon": "mmind.png",
|
||||||
|
"version":"0.01",
|
||||||
|
"description": "This is the classic game for masterminds",
|
||||||
|
"type": "game",
|
||||||
|
"tags": "mastermind, game, classic",
|
||||||
|
"readme":"README.md",
|
||||||
|
"supports": ["BANGLEJS2"],
|
||||||
|
"allow_emulator": true,
|
||||||
|
"storage": [
|
||||||
|
{"name":"mmind.app.js","url":"mmind.app.js"},
|
||||||
|
{"name":"mmind.img","url":"mmind.icon.js","evaluate":true}
|
||||||
|
]
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 712 B |
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
|
|
@ -3,3 +3,4 @@
|
||||||
0.03: Fix unfreed memory, and clearInterval that disabled all clocks at midnight
|
0.03: Fix unfreed memory, and clearInterval that disabled all clocks at midnight
|
||||||
Fix app icon
|
Fix app icon
|
||||||
Change menu order so 'back' is at the top
|
Change menu order so 'back' is at the top
|
||||||
|
0.04: Fix alarm not activating sometimes.
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ let alarms = require("Storage").readJSON("qalarm.json", 1) || [];
|
||||||
let active = alarms.filter(
|
let active = alarms.filter(
|
||||||
(alarm) =>
|
(alarm) =>
|
||||||
alarm.on &&
|
alarm.on &&
|
||||||
alarm.t < t &&
|
alarm.t <= t &&
|
||||||
alarm.last != time.getDate() &&
|
alarm.last != time.getDate() &&
|
||||||
(alarm.timer || alarm.daysOfWeek[time.getDay()])
|
(alarm.timer || alarm.daysOfWeek[time.getDay()])
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ layoutObject has:
|
||||||
optional `scale` specifies if image should be scaled up or not
|
optional `scale` specifies if image should be scaled up or not
|
||||||
* `"custom"` - a custom block where `render(layoutObj)` is called to render
|
* `"custom"` - a custom block where `render(layoutObj)` is called to render
|
||||||
* `"h"` - Horizontal layout, `c` is an array of more `layoutObject`
|
* `"h"` - Horizontal layout, `c` is an array of more `layoutObject`
|
||||||
* `"v"` - Veritical layout, `c` is an array of more `layoutObject`
|
* `"v"` - Vertical layout, `c` is an array of more `layoutObject`
|
||||||
* A `id` field. If specified the object is added with this name to the
|
* A `id` field. If specified the object is added with this name to the
|
||||||
returned `layout` object, so can be referenced as `layout.foo`
|
returned `layout` object, so can be referenced as `layout.foo`
|
||||||
* A `font` field, eg `6x8` or `30%` to use a percentage of screen height
|
* A `font` field, eg `6x8` or `30%` to use a percentage of screen height
|
||||||
|
|
@ -261,6 +261,7 @@ Layout.prototype.render = function (l) {
|
||||||
x,y+4
|
x,y+4
|
||||||
], bg = l.selected?g.theme.bgH:g.theme.bg2;
|
], bg = l.selected?g.theme.bgH:g.theme.bg2;
|
||||||
g.setColor(bg).fillPoly(poly).setColor(l.selected ? g.theme.fgH : g.theme.fg2).drawPoly(poly);
|
g.setColor(bg).fillPoly(poly).setColor(l.selected ? g.theme.fgH : g.theme.fg2).drawPoly(poly);
|
||||||
|
if (l.col) g.setColor(l.col);
|
||||||
if (l.src) g.setBgColor(bg).drawImage("function"==typeof l.src?l.src():l.src, l.x + 10 + (0|l.pad), l.y + 8 + (0|l.pad));
|
if (l.src) g.setBgColor(bg).drawImage("function"==typeof l.src?l.src():l.src, l.x + 10 + (0|l.pad), l.y + 8 + (0|l.pad));
|
||||||
else g.setFont("6x8",2).setFontAlign(0,0,l.r).drawString(l.label,l.x+l.w/2,l.y+l.h/2);
|
else g.setFont("6x8",2).setFontAlign(0,0,l.r).drawString(l.label,l.x+l.w/2,l.y+l.h/2);
|
||||||
}, "img":function(l){
|
}, "img":function(l){
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue