Skip to content

Commit

Permalink
3.1.2 Backlight will be enabled in the first 8 seconds of meditation …
Browse files Browse the repository at this point in the history
…then disabled to save battery in all devices and any activity type. For touch screen devices: Touch the screen to enable backlight and touch again to disable it. For button only devices: use the regular light button to enable/disable backlight. Notes: It will always respect backlight timeout configured in the watch. Also in touch devices sometime you will need to double tap in screen to enable backlight due to missing Connect IQ API to check if backlight is enabled already.
  • Loading branch information
dliedke committed Aug 2, 2022
1 parent 3eaf194 commit f8a1163
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Meditate/manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!-- This is a generated file. It is highly recommended that you DO NOT edit this file. -->
<iq:manifest xmlns:iq="http://www.garmin.com/xml/connectiq" version="3">
<iq:application entry="MeditateApp" id="9abb375dcf7c4ace87ff66f4f773f6c8" launcherIcon="@Drawables.launcherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watch-app" version="3.1.1">
<iq:application entry="MeditateApp" id="9abb375dcf7c4ace87ff66f4f773f6c8" launcherIcon="@Drawables.launcherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watch-app" version="3.1.2">
<iq:products>
<iq:product id="approachs62"/>
<iq:product id="d2air"/>
Expand Down
19 changes: 19 additions & 0 deletions Meditate/source/activity/MeditateDelegate.mc
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,23 @@ class MeditateDelegate extends Ui.BehaviorDelegate {
}
return false;
}

var backlightOn = false;

function onTap(clickEvent) {
try {

// Touch screen to disable/enable backlight during activity
// This will still respect the backligh timeout configured in the device
backlightOn = !backlightOn;
Attention.backlight(backlightOn);

} catch(ex) {

// Just in case we get a BacklightOnTooLongException for OLED display devices,
// disable backlight
backlightOn = false;
Attention.backlight(backlightOn);
}
}
}
12 changes: 11 additions & 1 deletion Meditate/source/activity/MeditateView.mc
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,17 @@ class MeditateView extends Ui.View {
me.mElapsedTime.draw(dc);

var alarmTime = me.mMeditateModel.getSessionTime();
me.mMainDuationRenderer.drawOverallElapsedTime(dc, me.mMeditateModel.elapsedTime, alarmTime);
var elapsedTime = me.mMeditateModel.elapsedTime;

// Enable backlight in the first 8 seconds then turn off to save battery
if (elapsedTime <= 8) {
Attention.backlight(true);
}
if (elapsedTime == 9) {
Attention.backlight(false);
}

me.mMainDuationRenderer.drawOverallElapsedTime(dc, elapsedTime, alarmTime);
if (me.mIntervalAlertsRenderer != null) {
me.mIntervalAlertsRenderer.drawRepeatIntervalAlerts(dc);
me.mIntervalAlertsRenderer.drawOneOffIntervalAlerts(dc);
Expand Down

0 comments on commit f8a1163

Please sign in to comment.