174 tidy up two small issues (#175)

Heading & vibrate
This commit is contained in:
Joseph Abbey
2024-08-29 21:18:03 +01:00
committed by GitHub
2 changed files with 19 additions and 4 deletions

View File

@ -112,7 +112,11 @@ class BackgroundServiceDelegate extends System.ServiceDelegate {
data.put("speed", Math.round(position.speed)); data.put("speed", Math.round(position.speed));
} }
if (position.heading != null) { if (position.heading != null) {
data.put("course", Math.round(position.heading * 180 / Math.PI)); var heading = Math.round(position.heading * 180 / Math.PI);
while (heading < 0) {
heading += 360;
}
data.put("course", heading);
} }
if (position.altitude != null) { if (position.altitude != null) {
data.put("altitude", Math.round(position.altitude)); data.put("altitude", Math.round(position.altitude));

View File

@ -25,9 +25,10 @@ using Toybox.Application.Properties;
using Toybox.Timer; using Toybox.Timer;
class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem { class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
private var mConfirm as Lang.Boolean; private var mConfirm as Lang.Boolean;
private var mData as Lang.Dictionary; private var mData as Lang.Dictionary;
private var mTemplate as Lang.String; private var mTemplate as Lang.String;
private var mHasVibrate as Lang.Boolean = false;
function initialize( function initialize(
label as Lang.String or Lang.Symbol, label as Lang.String or Lang.Symbol,
@ -40,6 +41,9 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
} or Null } or Null
) { ) {
WatchUi.ToggleMenuItem.initialize(label, null, null, false, options); WatchUi.ToggleMenuItem.initialize(label, null, null, false, options);
if (Attention has :vibrate) {
mHasVibrate = true;
}
mConfirm = confirm; mConfirm = confirm;
mData = data; mData = data;
mTemplate = template; mTemplate = template;
@ -198,6 +202,13 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
}, },
method(:onReturnSetState) method(:onReturnSetState)
); );
if (mHasVibrate and Settings.getVibrate()) {
Attention.vibrate([
new Attention.VibeProfile(50, 100), // On for 100ms
new Attention.VibeProfile( 0, 100), // Off for 100ms
new Attention.VibeProfile(50, 100) // On for 100ms
]);
}
} }
} }