Merge branch 'master' of github.com:espruino/BangleApps

master
Gordon Williams 2021-06-25 10:50:31 +01:00
commit 0688d79d3f
6 changed files with 280 additions and 7 deletions

View File

@ -3141,7 +3141,7 @@
{ "id": "kitchen",
"name": "Kitchen Combo",
"icon": "kitchen.png",
"version":"0.11",
"version":"0.12",
"description": "Combination of the Stepo, Walkersclock, Arrow and Waypointer apps into a multiclock format. 'Everything but the kitchen sink'. Requires firmware v2.08.167 or later",
"tags": "tool,outdoors,gps",
"type":"clock",
@ -3149,10 +3149,9 @@
"interface":"waypoints.html",
"storage": [
{"name":"kitchen.app.js","url":"kitchen.app.js"},
{"name":"stepo.kit.js","url":"stepo.kit.js"},
{"name":"gps.kit.js","url":"gps.kit.js"},
{"name":"digi.kit.js","url":"digi.kit.js"},
{"name":"stepo2.kit.js","url":"stepo2.kit.js"},
{"name":"swatch.kit.js","url":"swatch.kit.js"},
{"name":"gps.kit.js","url":"gps.kit.js"},
{"name":"compass.kit.js","url":"compass.kit.js"},
{"name":"kitchen.img","url":"kitchen.icon.js","evaluate":true}
],

View File

@ -9,3 +9,4 @@
0.09: Added heart rate monitor app
0.10: Converted Stepo to use direct screen writes, added a Trip Counter feature to stepo
0.11: Detect when waypoints.json is not present, error E-WPT
0.12: Added stepo2 as a replacement for stepo and digi

View File

@ -41,9 +41,25 @@ The following buttons depend on which face is currently in use
- Waypointer : select next waypoint
## Stepo2
![](screenshot_stepo2.jpg)
- Requires one of the pedominter widgets to be installed
- Stepo2 is a combination of Stepo and Digi and now replaces them
- Displays the time in large font
- Display current step count in a doughnut gauge
- The gauge show percentage of steps out of a goal of 10000 steps
- When the battery is less than 25% the doughnut turns red
- Use BTN1 to switch to the Trip Counter, use long press to reset Trip Counter
- Use BTN1 to cycle through the displays of Day,Date, Trip Counter, Battery %, Mem % and Firmware
- Use BTN3 to switch to the next app
## Stepo
![](screenshot_stepo.jpg)
- now replaced by Stepo2 but still available if you install manually
- Requires one of the pedominter widgets to be installed
- Displays the time in large font
- Display current step count in a doughnut gauge
@ -62,11 +78,13 @@ The following buttons depend on which face is currently in use
## Digi
![](screenshot_digi.jpg)
- now replaced by Stepo2 but still available if you install manually
- Displays the time in large font
- Display day and date
- Use BTN1 to switch between display of battery and memory %.
- Use BTN3 to switch to the next app.
## Swatch
![](screenshot_swatch.jpg)
- A simple stopwatch
@ -254,9 +272,8 @@ The following error codes will be displayed if one of the dependancies is not me
### Issues / Future enhancements
* Add a settings app so that 'Kitchen' based clocks can be enabled/disabled
* GPS time display shows GMT and not BST, needs localising
* Occassional buzzing after 2-3 days of use, seems to disappear after
a reset to the launcher menu. Needs investigation
* Automatically switch the GPS power setting from Super-E to PSMOO 10
seconds after the LCD goes off. At present I just rely on using
the GPSSetup app and set the GPS power mode that I want.

View File

@ -2,7 +2,7 @@
var FACES = [];
var STOR = require("Storage");
STOR.list(/\.kit\.js$/).forEach(face=>FACES.push(eval(require("Storage").read(face))));
var iface = STOR.list(/\.kit\.js$/).indexOf("stepo.kit.js");
var iface = STOR.list(/\.kit\.js$/).indexOf("stepo2.kit.js");
var face = FACES[iface]();
var firstPress
var pressTimer;

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

256
apps/kitchen/stepo2.kit.js Normal file
View File

@ -0,0 +1,256 @@
(() => {
function getFace(){
var intervalRefSec;
var trip;
var prevSteps;
var prevTopText1;
var prevTopText2;
var prevBottomText;
var prevMins;
var infoMode;
const INFO_DATE = 0;
const INFO_TRIP = 1;
const INFO_BATT = 2;
const INFO_MEM = 3;
const INFO_FW = 4;
function init(g,sw,hrm,tr) {
trip = tr;
infoMode = INFO_DATE;
forceRedraw();
}
function freeResources() {
trip = undefined;
}
function forceRedraw() {
prevStepsText = '';
prevSteps = -1;
prevTopText1 = '';
prevTopText2 = '';
prevBottomText = '';
prevMins = '';
}
function cycleInfoMode() {
switch(infoMode) {
case INFO_DATE:
infoMode = INFO_TRIP;
break;
case INFO_TRIP:
infoMode = INFO_BATT;
break;
case INFO_BATT:
infoMode = INFO_MEM
break;
case INFO_MEM:
infoMode = INFO_FW
break;
case INFO_FW:
default:
infoMode = INFO_DATE;
break;
}
}
function onButtonShort(btn) {
cycleInfoMode();
forceRedraw();
draw();
}
function onButtonLong(btn) {
trip.resetTrip(getSteps());
infoMode = INFO_TRIP;
forceRedraw();
draw();
}
function radians(a) {
return a*Math.PI/180;
}
function startTimer() {
draw();
intervalRefSec = setInterval(draw, 5000);
}
function stopTimer() {
if(intervalRefSec) {intervalRefSec=clearInterval(intervalRefSec);}
}
function draw() {
var d = new Date();
var da = d.toString().split(" ");
var hh = da[4].substr(0,2);
var mm = da[4].substr(3,2);
var day = da[0];
var day_month = da[2] + " " + da[1];
g.setColor(1,1,1); // white
if (prevMins != mm) {
prevMins = mm;
// hours and minutes
g.clearRect(0, 24, 149, 239);
g.setFontAlign(-1, -1);
g.setFont("Vector", 104);
g.drawString(hh, 20, 30, true);
g.drawString(mm, 20, 120, true);
}
/*
* if our trip count is greater than todays steps then we have
* rolled over to the next day so we should reset the trip counter
*/
var steps = getSteps();
if (trip.getTrip(steps) < 0)
trip.resetTrip(steps);
drawTopText(day,day_month);
drawBottomText();
drawSteps();
}
function drawTopText(dy, dm) {
var topText1 = "";
var topText2 = "";
switch(infoMode) {
case INFO_DATE:
topText1 = dy.toUpperCase();
topText2 = dm.toUpperCase();
break;
case INFO_TRIP:
topText2 = "TRIP";
break;
case INFO_BATT:
topText2 = "BATT";
break;
case INFO_MEM:
topText2 = "MEM";
break;
case INFO_FW:
topText2 = "F/W";
break;
}
if (prevTopText1 !== topText1 || prevTopText2 !== topText2) {
prevTopText1 = topText1;
prevTopText2 = topText2;
// day, date
g.setFont("Vector", 24);
g.setFontAlign(0, -1);
g.clearRect(150, 30, 239, 75);
g.drawString(topText1, 195, 30, true);
g.drawString(topText2, 195, 55, true);
}
}
function drawBottomText() {
var bottomText = "";
var steps = getSteps();
switch(infoMode) {
case INFO_DATE:
bottomText = "" + steps;
break;
case INFO_TRIP:
bottomText = "" + trip.getTrip(steps);
break;
case INFO_BATT:
bottomText = "" + E.getBattery() + "%";
break;
case INFO_MEM:
var val = process.memory();
bottomText = "" + Math.round(val.usage*100/val.total) + "%";
break;
case INFO_FW:
bottomText = process.env.VERSION;
break;
}
if (prevBottomText !== bottomText) {
prevBottomText = bottomText;
g.clearRect(148, 190, 239, 239);
g.setColor(1,1,1); // white
g.setFont("Vector", 24);
g.setFontAlign(0, -1);
g.drawString(bottomText, 195, 190);
}
}
function drawSteps() {
var i = 0;
var cx = 150 + 45;
var cy = 130;
var r = 34;
var steps = getSteps();
if (trip.getTripState() == true)
steps = trip.getTrip(steps);
if (prevSteps == steps)
return;
prevSteps = steps;
var percent = steps / 10000;
if (percent > 1) percent = 1;
var startrot = 0 - 180;
var midrot = -180 - (360 * percent);
var endrot = -360 - 180;
g.setColor(0x07FF); // light cyan
// draw guauge
for (i = startrot; i > midrot; i -= 3) {
x = cx + r * Math.sin(radians(i));
y = cy + r * Math.cos(radians(i));
g.fillCircle(x,y,3);
}
// change the remaining color to RED if battery is below 25%
if (E.getBattery() > 25) {
//g.setColor(0x7BEF); // grey
g.setColor(0x000D); // dark navy
} else {
g.setColor(0xF800); // red
}
// draw remainder of guage in grey or red
for (i = midrot - 12; i > endrot + 12; i -= 3) {
x = cx + r * Math.sin(radians(i));
y = cy + r * Math.cos(radians(i));
g.fillCircle(x,y,3);
}
}
function getSteps() {
if (stepsWidget() === undefined)
return "E-STEPS";
return stepsWidget().getSteps();
}
function stepsWidget() {
if (WIDGETS.activepedom !== undefined) {
return WIDGETS.activepedom;
} else if (WIDGETS.wpedom !== undefined) {
return WIDGETS.wpedom;
}
return undefined;
}
return {init:init, freeResources:freeResources, startTimer:startTimer, stopTimer:stopTimer,
onButtonShort:onButtonShort, onButtonLong:onButtonLong};
}
return getFace;
})();