Skip to content

Commit

Permalink
Added myprofile
Browse files Browse the repository at this point in the history
  • Loading branch information
nxdefiant committed Dec 10, 2023
1 parent b723512 commit 7fc2ce0
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
11 changes: 11 additions & 0 deletions apps/myprofile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# My Profile

Configure your personal profile. All settings are optional and are only stored on the watch.

## Available settings

| Setting | Description | Displayed in | Stored in | Default value | How to measure |
| ------------- | ----------------------------- | ------------------- | --------- | ------------- | ----------------------------------------------------------------- |
| HR max | maximum heart rate | BPM | BPM | 60 | Use maximum value when exercising.<br/> If unsure set to 220-age. |
| HR min | minimum heart rate | BPM | BPM | 200 | Measure your heart rate after waking up |
| Stride length | distance travel with one step | local length unit | meter | 0 (=not set) | Walk 10 steps and divide the travelled distance by 10 |
Binary file added apps/myprofile/app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions apps/myprofile/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ "id": "myprofile",
"name": "My Profile",
"shortName":"My Profile",
"icon": "app.png",
"type": "settings",
"version":"0.01",
"description": "Configure your personal profile. All settings are optional and only stored on the watch.",
"readme": "README.md",
"tags": "tool,utility",
"supports": ["BANGLEJS", "BANGLEJS2"],
"storage": [
{"name":"myprofile.settings.js","url":"settings.js"}
],
"data": [
{"name":"myprofile.json"}
]
}

52 changes: 52 additions & 0 deletions apps/myprofile/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
(function(back) {
const FILE = "myprofile.json";

const myprofile = Object.assign({
minHrm: 60,
maxHrm: 200,
strideLength: 0, // 0 = not set
}, require('Storage').readJSON(FILE, true) || {});

function writeProfile() {
require('Storage').writeJSON(FILE, myprofile);
}

// Show the menu
E.showMenu({
"" : { "title" : /*LANG*/"My Profile" },

"< Back" : () => back(),

/*LANG*/'HR max': {
format: v => /*LANG*/`${v} BPM`,
value: myprofile.maxHrm,
min: 30, max: 220,
onchange: v => {
myprofile.maxHrm = v;
writeProfile();
}
},

/*LANG*/'HR min': {
format: v => /*LANG*/`${v} BPM`,
value: myprofile.minHrm,
min: 30, max: 220,
onchange: v => {
myprofile.minHrm = v;
writeProfile();
}
},

/*LANG*/"Stride length": {
value: myprofile.strideLength,
min:0.00,
step:0.01,
format: v => v ? require("locale").distance(v, 2) : '-',
onchange: v => {
console.log(v);
myprofile.strideLength=v;
writeProfile();
},
},
});
})

0 comments on commit 7fc2ce0

Please sign in to comment.