Skip to content

Commit 17162c1

Browse files
authored
174 tidy up two small issues (#175)
Heading & vibrate
2 parents 63bc127 + b5140ce commit 17162c1

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

source/BackgroundServiceDelegate.mc

+5-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ class BackgroundServiceDelegate extends System.ServiceDelegate {
112112
data.put("speed", Math.round(position.speed));
113113
}
114114
if (position.heading != null) {
115-
data.put("course", Math.round(position.heading * 180 / Math.PI));
115+
var heading = Math.round(position.heading * 180 / Math.PI);
116+
while (heading < 0) {
117+
heading += 360;
118+
}
119+
data.put("course", heading);
116120
}
117121
if (position.altitude != null) {
118122
data.put("altitude", Math.round(position.altitude));

source/HomeAssistantToggleMenuItem.mc

+14-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ using Toybox.Application.Properties;
2525
using Toybox.Timer;
2626

2727
class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
28-
private var mConfirm as Lang.Boolean;
29-
private var mData as Lang.Dictionary;
30-
private var mTemplate as Lang.String;
28+
private var mConfirm as Lang.Boolean;
29+
private var mData as Lang.Dictionary;
30+
private var mTemplate as Lang.String;
31+
private var mHasVibrate as Lang.Boolean = false;
3132

3233
function initialize(
3334
label as Lang.String or Lang.Symbol,
@@ -40,6 +41,9 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
4041
} or Null
4142
) {
4243
WatchUi.ToggleMenuItem.initialize(label, null, null, false, options);
44+
if (Attention has :vibrate) {
45+
mHasVibrate = true;
46+
}
4347
mConfirm = confirm;
4448
mData = data;
4549
mTemplate = template;
@@ -198,6 +202,13 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
198202
},
199203
method(:onReturnSetState)
200204
);
205+
if (mHasVibrate and Settings.getVibrate()) {
206+
Attention.vibrate([
207+
new Attention.VibeProfile(50, 100), // On for 100ms
208+
new Attention.VibeProfile( 0, 100), // Off for 100ms
209+
new Attention.VibeProfile(50, 100) // On for 100ms
210+
]);
211+
}
201212
}
202213
}
203214

0 commit comments

Comments
 (0)