Skip to content

Commit

Permalink
Added permanent backlight feature
Browse files Browse the repository at this point in the history
Check for pushes of the start/stop button in quick succession (1.5s),
and toggle forcing the backlight to stay on accordingly.
  • Loading branch information
imgrant committed Feb 3, 2017
1 parent 6014184 commit df8c8af
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 2 deletions.
2 changes: 1 addition & 1 deletion manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- // Release config -->
<iq:application entry="FlexiRunnerApp" id="c690fd92d1ea4538b4e2116fc1a4b31b" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="1.3.0" name="@Strings.AppName" type="datafield">
<!-- // Development/beta config
<iq:application entry="FlexiRunnerApp" id="a1b63282d0d7491ab3e8735bc070dd05" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="1.3.1" name="@Strings.AppName" type="datafield">
<iq:application entry="FlexiRunnerApp" id="a1b63282d0d7491ab3e8735bc070dd05" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="1.3.0" name="@Strings.AppName" type="datafield">
-->
<iq:products>
<iq:product id="fr630"/>
Expand Down
2 changes: 1 addition & 1 deletion resources/properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<!-- Beta name:
<string id="AppName">Flexirunner Beta</string>
-->
<string id="AppVersion">6.0.1</string>
<string id="AppVersion">6.1.0</string>
<string id="lTimerDisplay">Timer field</string>
<string id="lTimerTimer">Timer</string>
<string id="lTimerMoving">Moving time</string>
Expand Down
24 changes: 24 additions & 0 deletions source/FlexiRunnerApp-rectangle-148x205.mc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {
//! true => Show current pace as Rounded Pace (i.e. rounded to 5 second intervals)
//! false => Show current pace without rounding (i.e. 1-second resolution)

hidden var uBacklight = false;
//! true => Force the backlight to stay on permanently
//! false => Use the defined backlight timeout as normal

hidden var uBottomLeftMetric = 1; //! Data to show in bottom left field
hidden var uBottomRightMetric = 0; //! Data to show in bottom right field
//! Lower fields enum:
Expand All @@ -48,6 +52,7 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {
//! 7 => Energy expenditure

hidden var mTimerRunning = false;
hidden var mStartStopPushed = 0; //! Timer value when the start/stop button was last pushed

hidden var mStoppedTime = 0;
hidden var mStoppedDistance = 0;
Expand Down Expand Up @@ -134,6 +139,11 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {
mLapEconomyField.setData(mLapEconomy.toNumber());

mPrevElapsedDistance = mElapsedDistance;

//! If enabled, switch the backlight on in order to make it stay on
if (uBacklight) {
Attention.backlight(true);
}
}

var mEconomy = 0;
Expand Down Expand Up @@ -192,12 +202,24 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {

//! Timer transitions from stopped to running state
function onTimerStart() {
var info = Activity.getActivityInfo();
//! If the start/stop button was last pushed less than 1.5 seconds ago,
//! toggle the force backlight feature (see in compute(), above).
//! That is, press the start/stop button twice in quick succession
//! to make the backlight stay on, or revert to the normal timeout
//! setting as configured on the watch.
if ( ( info.elapsedTime > 0 ) && ( (info.elapsedTime - mStartStopPushed) < 1500 ) ) {
uBacklight = !uBacklight;
}
mStartStopPushed = info.elapsedTime;
mTimerRunning = true;
}


//! Timer transitions from running to stopped state
function onTimerStop() {
var info = Activity.getActivityInfo();
mStartStopPushed = info.elapsedTime;
mTimerRunning = false;
}

Expand Down Expand Up @@ -232,6 +254,8 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {
mLastLapCalories = 0;

mEconomySmooth = 0;

mStartStopPushed = 0;
}


Expand Down
24 changes: 24 additions & 0 deletions source/FlexiRunnerApp-rectangle-205x148.mc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {
//! true => Show current pace as Rounded Pace (i.e. rounded to 5 second intervals)
//! false => Show current pace without rounding (i.e. 1-second resolution)

hidden var uBacklight = false;
//! true => Force the backlight to stay on permanently
//! false => Use the defined backlight timeout as normal

hidden var uBottomLeftMetric = 1; //! Data to show in bottom left field
hidden var uBottomRightMetric = 0; //! Data to show in bottom right field
//! Lower fields enum:
Expand All @@ -48,6 +52,7 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {
//! 7 => Energy expenditure

hidden var mTimerRunning = false;
hidden var mStartStopPushed = 0; //! Timer value when the start/stop button was last pushed

hidden var mStoppedTime = 0;
hidden var mStoppedDistance = 0;
Expand Down Expand Up @@ -134,6 +139,11 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {
mLapEconomyField.setData(mLapEconomy.toNumber());

mPrevElapsedDistance = mElapsedDistance;

//! If enabled, switch the backlight on in order to make it stay on
if (uBacklight) {
Attention.backlight(true);
}
}

var mEconomy = 0;
Expand Down Expand Up @@ -192,12 +202,24 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {

//! Timer transitions from stopped to running state
function onTimerStart() {
var info = Activity.getActivityInfo();
//! If the start/stop button was last pushed less than 1.5 seconds ago,
//! toggle the force backlight feature (see in compute(), above).
//! That is, press the start/stop button twice in quick succession
//! to make the backlight stay on, or revert to the normal timeout
//! setting as configured on the watch.
if ( ( info.elapsedTime > 0 ) && ( (info.elapsedTime - mStartStopPushed) < 1500 ) ) {
uBacklight = !uBacklight;
}
mStartStopPushed = info.elapsedTime;
mTimerRunning = true;
}


//! Timer transitions from running to stopped state
function onTimerStop() {
var info = Activity.getActivityInfo();
mStartStopPushed = info.elapsedTime;
mTimerRunning = false;
}

Expand Down Expand Up @@ -232,6 +254,8 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {
mLastLapCalories = 0;

mEconomySmooth = 0;

mStartStopPushed = 0;
}


Expand Down
24 changes: 24 additions & 0 deletions source/FlexiRunnerApp-round.mc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {
//! true => Show current pace as Rounded Pace (i.e. rounded to 5 second intervals)
//! false => Show current pace without rounding (i.e. 1-second resolution)

hidden var uBacklight = false;
//! true => Force the backlight to stay on permanently
//! false => Use the defined backlight timeout as normal

hidden var uBottomLeftMetric = 1; //! Data to show in bottom left field
hidden var uBottomRightMetric = 0; //! Data to show in bottom right field
//! Lower fields enum:
Expand All @@ -48,6 +52,7 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {
//! 7 => Energy expenditure

hidden var mTimerRunning = false;
hidden var mStartStopPushed = 0; //! Timer value when the start/stop button was last pushed

hidden var mStoppedTime = 0;
hidden var mStoppedDistance = 0;
Expand Down Expand Up @@ -134,6 +139,11 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {
mLapEconomyField.setData(mLapEconomy.toNumber());

mPrevElapsedDistance = mElapsedDistance;

//! If enabled, switch the backlight on in order to make it stay on
if (uBacklight) {
Attention.backlight(true);
}
}

var mEconomy = 0;
Expand Down Expand Up @@ -192,12 +202,24 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {

//! Timer transitions from stopped to running state
function onTimerStart() {
var info = Activity.getActivityInfo();
//! If the start/stop button was last pushed less than 1.5 seconds ago,
//! toggle the force backlight feature (see in compute(), above).
//! That is, press the start/stop button twice in quick succession
//! to make the backlight stay on, or revert to the normal timeout
//! setting as configured on the watch.
if ( ( info.elapsedTime > 0 ) && ( (info.elapsedTime - mStartStopPushed) < 1500 ) ) {
uBacklight = !uBacklight;
}
mStartStopPushed = info.elapsedTime;
mTimerRunning = true;
}


//! Timer transitions from running to stopped state
function onTimerStop() {
var info = Activity.getActivityInfo();
mStartStopPushed = info.elapsedTime;
mTimerRunning = false;
}

Expand Down Expand Up @@ -232,6 +254,8 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {
mLastLapCalories = 0;

mEconomySmooth = 0;

mStartStopPushed = 0;
}


Expand Down
24 changes: 24 additions & 0 deletions source/FlexiRunnerApp-semiround.mc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {
//! true => Show current pace as Rounded Pace (i.e. rounded to 5 second intervals)
//! false => Show current pace without rounding (i.e. 1-second resolution)

hidden var uBacklight = false;
//! true => Force the backlight to stay on permanently
//! false => Use the defined backlight timeout as normal

hidden var uBottomLeftMetric = 1; //! Data to show in bottom left field
hidden var uBottomRightMetric = 0; //! Data to show in bottom right field
//! Lower fields enum:
Expand All @@ -48,6 +52,7 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {
//! 7 => Energy expenditure

hidden var mTimerRunning = false;
hidden var mStartStopPushed = 0; //! Timer value when the start/stop button was last pushed

hidden var mStoppedTime = 0;
hidden var mStoppedDistance = 0;
Expand Down Expand Up @@ -134,6 +139,11 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {
mLapEconomyField.setData(mLapEconomy.toNumber());

mPrevElapsedDistance = mElapsedDistance;

//! If enabled, switch the backlight on in order to make it stay on
if (uBacklight) {
Attention.backlight(true);
}
}

var mEconomy = 0;
Expand Down Expand Up @@ -192,12 +202,24 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {

//! Timer transitions from stopped to running state
function onTimerStart() {
var info = Activity.getActivityInfo();
//! If the start/stop button was last pushed less than 1.5 seconds ago,
//! toggle the force backlight feature (see in compute(), above).
//! That is, press the start/stop button twice in quick succession
//! to make the backlight stay on, or revert to the normal timeout
//! setting as configured on the watch.
if ( ( info.elapsedTime > 0 ) && ( (info.elapsedTime - mStartStopPushed) < 1500 ) ) {
uBacklight = !uBacklight;
}
mStartStopPushed = info.elapsedTime;
mTimerRunning = true;
}


//! Timer transitions from running to stopped state
function onTimerStop() {
var info = Activity.getActivityInfo();
mStartStopPushed = info.elapsedTime;
mTimerRunning = false;
}

Expand Down Expand Up @@ -232,6 +254,8 @@ class FlexiRunnerView extends Toybox.WatchUi.DataField {
mLastLapCalories = 0;

mEconomySmooth = 0;

mStartStopPushed = 0;
}


Expand Down

0 comments on commit df8c8af

Please sign in to comment.