Skip to content

Commit 326b97d

Browse files
authored
Merge branch 'espruino:master' into master
2 parents 19b963d + 2eb84e3 commit 326b97d

30 files changed

Lines changed: 697 additions & 39 deletions

apps/bluewatch/ChangeLog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
0.01: New App!
2-
0.02: Use new device handshake method for more reliable connections (Must use the iOS BlueWatch app version 1.1)
2+
0.02: Use new device handshake method for more reliable connections (Requires BlueWatch on iOS version 1.1)
3+
0.03: Fix data intervals firing randomly, pairing issues, increased time between battery pushing, and queued data sending (Requires BlueWatch on iOS version 1.2)

apps/bluewatch/boot.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
NRF.setAdvertising({}, { connectable: true });
21

32
var blueWatch = require("bluewatch");
43
var settings = require("Storage").readJSON("bluewatch.settings.json") || {
@@ -14,19 +13,25 @@ let appsUsingGPS = savedData.appsUsingGPS || [];
1413
global.phoneConnected = savedData.phoneConnected;
1514

1615
function updateWeatherAndLocation() {
17-
blueWatch.sendData("Request Location");
16+
blueWatch.sendData("Request Location",true);
1817
setTimeout(function () {
19-
blueWatch.sendData("Request Weather");
18+
blueWatch.sendData("Request Weather",true);
2019
}, 60 * 10);
2120
}
2221
function setUpdateIntervals() {
22+
if (weatherLocInterval)
23+
clearInterval(weatherLocInterval);
24+
25+
if (systemDataInterval)
26+
clearInterval(systemDataInterval);
27+
2328
weatherLocInterval = setInterval(updateWeatherAndLocation, 10 * 60 * 1000);
24-
systemDataInterval = setInterval(blueWatch.sendSystemData, 60 * 1000);
29+
systemDataInterval = setInterval(blueWatch.sendSystemData, 6 * 60 * 1000); // 6 mins
2530
}
31+
2632
Bangle.on("BlueWatchConnected", function () {
2733
blueWatch.sendSystemData();
2834
updateWeatherAndLocation();
29-
blueWatch.sendHealthData();
3035
setUpdateIntervals();
3136
});
3237
if (global.phoneConnected) {

apps/bluewatch/lib.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
11
let interval;
22
let rxBuffer = ""; // accumulates incoming chunks
3+
let queue = [];
4+
let sending = false;
35

4-
NRF.setAdvertising({}, { connectable: true });
6+
function queueSend(msg) {
7+
queue.push(msg);
8+
sendNext();
9+
}
10+
11+
function sendNext() {
12+
if (sending) return;
13+
if (!queue.length) return;
14+
15+
sending = true;
16+
17+
Bluetooth.write(queue.shift());
18+
19+
setTimeout(function() {
20+
sending = false;
21+
sendNext();
22+
},40);
23+
}
524

625
exports.sendSystemData = function () {
726
let data = {
@@ -47,9 +66,7 @@ function updateWeatherData(d) {
4766

4867
function sendData(dataString, forceSend) {
4968
if (global.phoneConnected || forceSend) {
50-
setTimeout(function () {
51-
Bluetooth.write(dataString + "\n");
52-
}, 500);
69+
queueSend("bwRX:"+dataString+"\n");
5370
} else {
5471
print("Phone not connected");
5572
}
@@ -146,9 +163,12 @@ function processMessage(raw) {
146163

147164
if (obj) {
148165
switch (obj.id) {
149-
case "WeatherUpdate":
166+
case "Weather":
150167
updateWeatherData(obj);
151168
break;
169+
case "GPS":
170+
Bangle.emit("GPS", obj);
171+
break;
152172
}
153173
}
154174
}
@@ -159,7 +179,6 @@ function messageReceived(data) {
159179
data = String(data);
160180
}
161181
rxBuffer += data;
162-
163182
// 2. Check if the delimiter exists
164183
let idx = rxBuffer.indexOf("|");
165184

apps/bluewatch/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"id": "bluewatch",
33
"name": "BlueWatch iOS Integration",
44
"shortName": "BlueWatch",
5-
"version": "0.02",
6-
"description": "Uses the native iOS app 'BlueWatch' to fetch weather, use phone GPS, find phone/watch, and more.",
5+
"version": "0.03",
6+
"description": "Uses the native iOS app 'BlueWatch' to fetch weather, location, use phone GPS, find phone/watch, and more.",
77
"icon": "app.png",
88
"tags": "tool,bluetooth,apple,ios,system",
99
"supports": ["BANGLEJS2"],

apps/hrm/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
0.11: Automatic translation of strings.
1212
0.12: Minor code improvements
1313
0.13: Minor code improvements
14+
0.14: Ensure we reset graphics so other apps can't mess up the background color

apps/hrm/heartrate.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function onHRM(h) {
1414
// the first time we're called remove
1515
// the countdown
1616
counter = undefined;
17-
g.clearRect(0,24,g.getWidth(),g.getHeight());
17+
g.reset().clearRect(0,24,g.getWidth(),g.getHeight());
1818
}
1919
hrmInfo = h;
2020
/* On 2v09 and earlier firmwares the only solution for realtime
@@ -35,7 +35,7 @@ Bangle.on('HRM', onHRM);
3535

3636
function updateHrm(){
3737
var px = g.getWidth()/2;
38-
g.setFontAlign(0,-1);
38+
g.reset().setFontAlign(0,-1);
3939
g.clearRect(0,24,g.getWidth(),80);
4040
g.setFont("6x8").drawString(/*LANG*/"Confidence "+(hrmInfo.confidence || "--")+"%", px, 70);
4141

@@ -62,6 +62,7 @@ var scale = 2000;
6262
HRM events as they happen */
6363
Bangle.on('HRM-raw', function(v) {
6464
hrmOffset++;
65+
g.reset();
6566
if (hrmOffset>g.getWidth()) {
6667
let thousands = Math.round(rawMax / 1000) * 1000;
6768
if (thousands > scale) scale = thousands;
@@ -91,11 +92,11 @@ Bangle.on('HRM-raw', function(v) {
9192
var counter = 5;
9293
function countDown() {
9394
if (counter) {
94-
g.drawString(counter--,g.getWidth()/2,g.getHeight()/2, true);
95+
g.reset().drawString(counter--,g.getWidth()/2,g.getHeight()/2, true);
9596
setTimeout(countDown, 1000);
9697
}
9798
}
98-
g.clear();
99+
g.clear(1);
99100
Bangle.loadWidgets();
100101
Bangle.drawWidgets();
101102
g.setColor(g.theme.fg);
@@ -111,7 +112,7 @@ var hrmInfo;
111112

112113
function readHRM() {
113114
if (!hrmInfo) return;
114-
115+
g.reset();
115116
if (hrmOffset==0) {
116117
g.clearRect(0,100,g.getWidth(),g.getHeight());
117118
lastHrmPt = [-100,0];

apps/hrm/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"id": "hrm",
33
"name": "Heart Rate Monitor",
4-
"version": "0.13",
5-
"author": "ra100",
4+
"version": "0.14",
5+
"author": "gfwilliams",
66
"description": "Measure your heart rate and see live sensor data",
77
"icon": "heartrate.png",
88
"screenshots" : [ { "url":"screenshot.png" } ],

apps/iconlaunch/ChangeLog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@
2727
0.20: Use '28' font if installed (2v26+) and put it inside a rounded rect in the current theme
2828
Ensure 'oneClickExit' is the default
2929
0.21: Display placeholder icons at start and render line by line to the screen to make loading seem faster
30-
0.22: Use launcher_utils library for app cacheing and fast load
30+
0.22: Use launcher_utils library for app cacheing and fast load
31+
0.23: Use Bangle.haptic if available

apps/iconlaunch/app.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,14 @@
9898
let selectItem = function(id, e) {
9999
const iconN = E.clip(Math.floor((e.x - R.x) / itemSize), 0, appsN - 1);
100100
const appId = id * appsN + iconN;
101-
if( settings.direct && launchCache.apps[appId])
101+
if( settings.direct && launchCache.apps[appId]) {
102+
if(Bangle.haptic) Bangle.haptic("touch");
102103
return require("launch_utils").loadApp(launchCache.apps[appId]);
103-
if (appId == selectedItem && launchCache.apps[appId])
104+
}
105+
if (appId == selectedItem && launchCache.apps[appId]) {
106+
if(Bangle.haptic) Bangle.haptic("touch");
104107
return require("launch_utils").loadApp(launchCache.apps[appId]);
105-
108+
}
106109
selectedItem = appId;
107110
if (scroller) scroller.draw();
108111
};
@@ -155,4 +158,4 @@
155158
Bangle.on("touch", updateTimeout);
156159

157160
updateTimeout();
158-
}
161+
}

apps/iconlaunch/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "iconlaunch",
33
"name": "Icon Launcher",
44
"shortName" : "Icon launcher",
5-
"version": "0.22",
5+
"version": "0.23",
66
"icon": "app.png",
77
"author": "TheGLander",
88
"description": "A launcher inspired by smartphones, with an icon-only scrollable menu.",

0 commit comments

Comments
 (0)