mirror of https://github.com/espruino/BangleApps
parent
7caac64a86
commit
8580952e69
|
@ -5,10 +5,11 @@ A simple widget that display several measurements as vertical bars.
|
||||||

|

|
||||||
|
|
||||||
## Measurements from left to right:
|
## Measurements from left to right:
|
||||||
|
<!-- HRM and Temperature are commented out (they didn't seem very useful)
|
||||||
- Current heart rate, on a scale from 0-200 bpm (*red*)<br>
|
- Current heart rate, on a scale from 0-200 bpm (*red*)<br>
|
||||||
Only if available: this widget does not turn on HRM monitoring by itself.
|
Only if available: this widget does not turn on HRM monitoring by itself.
|
||||||
- Device temperature, on a scale from 0-50 °C (*yellow*)
|
- Device temperature, on a scale from 0-50 °C (*yellow*)
|
||||||
|
-->
|
||||||
- Flash storage space used (*blue/cyan*)
|
- Flash storage space used (*blue/cyan*)
|
||||||
- Memory usage (*magenta*)
|
- Memory usage (*magenta*)
|
||||||
- Battery charge (*green*)
|
- Battery charge (*green*)
|
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 9.6 KiB |
|
@ -3,22 +3,27 @@
|
||||||
w=3, // width of single bar
|
w=3, // width of single bar
|
||||||
bars=3; // number of bars
|
bars=3; // number of bars
|
||||||
|
|
||||||
// We show HRM if available, but don't turn it on
|
// Note: HRM/temperature are commented out (they didn't seem very useful)
|
||||||
let bpm,rst,con=10; // always ignore HRM with confidence below 10%
|
// If re-adding them, also adjust `bars`
|
||||||
function noHrm() { // last value is no longer valid
|
|
||||||
if (rst) clearTimeout(rst);
|
// ==HRM start==
|
||||||
rst=bpm=undefined; con=10;
|
// // We show HRM if available, but don't turn it on
|
||||||
WIDGETS["bars"].draw();
|
// let bpm,rst,con=10; // always ignore HRM with confidence below 10%
|
||||||
}
|
// function noHrm() { // last value is no longer valid
|
||||||
Bangle.on('HRM', hrm=>{
|
// if (rst) clearTimeout(rst);
|
||||||
if (hrm.confidence>con || hrm.confidence>=80) {
|
// rst=bpm=undefined; con=10;
|
||||||
bpm=hrm.confidence;
|
// WIDGETS["bars"].draw();
|
||||||
con=hrm.confidence;
|
// }
|
||||||
WIDGETS["bars"].draw();
|
// Bangle.on('HRM', hrm=>{
|
||||||
if (rst) clearTimeout(rst);
|
// if (hrm.confidence>con || hrm.confidence>=80) {
|
||||||
rst = setTimeout(noHrm, 10*60*1000); // forget HRM after 10 minutes
|
// bpm=hrm.confidence;
|
||||||
}
|
// con=hrm.confidence;
|
||||||
});
|
// WIDGETS["bars"].draw();
|
||||||
|
// if (rst) clearTimeout(rst);
|
||||||
|
// rst = setTimeout(noHrm, 10*60*1000); // forget HRM after 10 minutes
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// ==HRM end==
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a bar
|
* Draw a bar
|
||||||
|
@ -42,8 +47,8 @@
|
||||||
const x = this.x, y = this.y,
|
const x = this.x, y = this.y,
|
||||||
m = process.memory();
|
m = process.memory();
|
||||||
let b=0;
|
let b=0;
|
||||||
bar(x+(w*b++),y,'#f00'/*red */,bpm/200); // >200 seems very unhealthy; if we have no valid bpm this will just be empty space
|
// ==HRM== bar(x+(w*b++),y,'#f00'/*red */,bpm/200); // >200 seems very unhealthy; if we have no valid bpm this will just be empty space
|
||||||
bar(x+(w*b++),y,'#ff0'/*yellow */,E.getTemperature()/50); // you really don't want to wear a watch that's hotter than 50°C
|
// ==Temperature== bar(x+(w*b++),y,'#ff0'/*yellow */,E.getTemperature()/50); // you really don't want to wear a watch that's hotter than 50°C
|
||||||
bar(x+(w*b++),y,g.theme.dark?'#0ff':'#00f'/*cyan/blue*/,1-(require('Storage').getFree() / process.env.STORAGE));
|
bar(x+(w*b++),y,g.theme.dark?'#0ff':'#00f'/*cyan/blue*/,1-(require('Storage').getFree() / process.env.STORAGE));
|
||||||
bar(x+(w*b++),y,'#f0f'/*magenta*/,m.usage/m.total);
|
bar(x+(w*b++),y,'#f0f'/*magenta*/,m.usage/m.total);
|
||||||
bar(x+(w*b++),y,'#0f0'/*green */,E.getBattery()/100);
|
bar(x+(w*b++),y,'#0f0'/*green */,E.getBattery()/100);
|
||||||
|
|
Loading…
Reference in New Issue