Skip to content

Commit f7c1b1b

Browse files
committed
Add menu to allow altitude to be calibrated
1 parent 254d333 commit f7c1b1b

File tree

4 files changed

+66
-14
lines changed

4 files changed

+66
-14
lines changed

apps/setting/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,4 @@ of 'Select Clock'
8484
0.73: Fix `const` bug / work with fastload
8585
0.74: Add extra layer of checks before allowing a factory reset (fix #3476)
8686
0.75: Restore previous menu's scroll positions
87+
0.76: Add altitude calibration menu (and update README after menu changed)

apps/setting/README.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
11
# Settings
22

3-
This is Bangle.js's settings menu
3+
This is Bangle.js's main settings menu:
4+
5+
* **Apps** - Settings for installed apps/widgets
6+
* **System** - Settings related to themes, default apps, date & time, etc
7+
* **Bluetooth** - Bluetooth Settings menu - see below.
8+
* **Alerts** - Set how Bangle.js alerts you (including Quiet mode)
9+
* **Utils** - Utilities, including resetting settings
10+
11+
See below for options under each heading:
12+
13+
## System - System settings
14+
15+
* **Theme** Adjust the colour scheme
16+
* **LCD** Configure settings about the screen. How long it stays on, how bright it is, and when it turns on - see below.
17+
* **Locale** set time zone, the time format (12/24h, for supported clocks) and the first day of the week
18+
* **Clock** if you have more than one clock face, select the default one
19+
* **Launcher** if you have more than one app launcher, select the default one
20+
* **Date & Time** Configure the current time - Note that this can be done much more easily by choosing 'Set Time' from the App Loader
21+
* **Altitude** On Bangle.js 2, adjust the altitude (
22+
23+
## Alerts
424

5-
* **App/Widget Settings** settings specific to installed applications
6-
* **BLE** Bluetooth Settings menu - see below.
725
* **Beep** most Bangle.js do not have a speaker inside, but they can use the vibration motor to beep in different pitches. You can change the behaviour here to use a Piezo speaker if one is connected
826
* **Vibration** enable/disable the vibration motor
927
* **Quiet Mode** prevent notifications/alarms from vibrating/beeping/turning the screen on - see below
10-
* **Locale** set time zone, the time format (12/24h, for supported clocks) and the first day of the week
11-
* **Select Clock** if you have more than one clock face, select the default one
12-
* **Date & Time** Configure the current time - Note that this can be done much more easily by choosing 'Set Time' from the App Loader
13-
* **LCD** Configure settings about the screen. How long it stays on, how bright it is, and when it turns on - see below.
14-
* **Theme** Adjust the colour scheme
15-
* **Utils** Utilities - including resetting settings (see below)
1628

17-
## BLE - Bluetooth Settings
29+
## Bluetooth
1830

1931
* **Make Connectable** regardless of the current Bluetooth settings, makes Bangle.js so you can connect to it (while the window is up)
2032
* **BLE** is Bluetooth LE enabled and the watch connectable?

apps/setting/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "setting",
33
"name": "Settings",
4-
"version": "0.75",
4+
"version": "0.76",
55
"description": "A menu for setting up Bangle.js",
66
"icon": "settings.png",
77
"tags": "tool,system",

apps/setting/settings.js

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{
21
Bangle.loadWidgets();
32
Bangle.drawWidgets();
43

@@ -110,7 +109,6 @@ function mainMenu() {
110109
}
111110

112111
function systemMenu() {
113-
114112
const mainmenu = {
115113
'': { 'title': /*LANG*/'System' },
116114
'< Back': ()=>popMenu(mainMenu()),
@@ -121,6 +119,7 @@ function systemMenu() {
121119
/*LANG*/'Launcher': ()=>pushMenu(launcherMenu()),
122120
/*LANG*/'Date & Time': ()=>pushMenu(setTimeMenu())
123121
};
122+
if (Bangle.getPressure) mainmenu[/*LANG*/"Altitude"] = ()=>pushMenu(showAltitude());
124123

125124
return mainmenu;
126125
}
@@ -1030,5 +1029,45 @@ function showTouchscreenCalibration() {
10301029
showTapSpot();
10311030
}
10321031

1033-
pushMenu(mainMenu());
1032+
// Calibrate altitude - Bangle.js2 only
1033+
function showAltitude() {
1034+
function onPressure(pressure) {
1035+
menuPressure.value = Math.round(pressure.pressure);
1036+
menuAltitude.value = Math.round(pressure.altitude);
1037+
m.draw();
1038+
}
1039+
Bangle.setBarometerPower(1,"settings");
1040+
Bangle.on("pressure",onPressure);
1041+
var seaLevelPressure = Bangle.getOptions().seaLevelPressure;
1042+
if (!isFinite(seaLevelPressure)) seaLevelPressure=1013.25;
1043+
var menuPressure = {value:"-"};
1044+
var menuAltitude = {value:"-"};
1045+
var m = E.showMenu({ "" : {title:/*LANG*/"Altitude",back:() => {
1046+
Bangle.setBarometerPower(0,"settings");
1047+
Bangle.removeListener("pressure",onPressure);
1048+
settings.seaLevelPressure = seaLevelPressure;
1049+
updateSettings();
1050+
popMenu(systemMenu());
1051+
}},
1052+
/*LANG*/"Pressure (hPa)" : menuPressure,
1053+
/*LANG*/"Altitude (m)" : menuAltitude,
1054+
/*LANG*/"Adjust up" : function() {
1055+
Bangle.buzz(80);
1056+
seaLevelPressure++;
1057+
Bangle.setOptions({seaLevelPressure:seaLevelPressure});
1058+
},
1059+
/*LANG*/"Adjust down" : function() {
1060+
Bangle.buzz(80);
1061+
seaLevelPressure--;
1062+
Bangle.setOptions({seaLevelPressure:seaLevelPressure});
1063+
},
1064+
/*LANG*/"Set Default" : function() {
1065+
Bangle.buzz();
1066+
seaLevelPressure=1013.25;
1067+
Bangle.setOptions({seaLevelPressure:seaLevelPressure});
1068+
}
1069+
});
10341070
}
1071+
1072+
// Show the main menu
1073+
pushMenu(mainMenu());

0 commit comments

Comments
 (0)