From daf4aac80607c8089e865fd26634c087b122e692 Mon Sep 17 00:00:00 2001 From: Dan Siwiec Date: Sun, 15 May 2016 18:07:15 -0700 Subject: [PATCH] Turn beeps off for vivoactive --- build.sh | 11 ----------- deploy.sh | 1 - run.sh | 1 - source/TabataModel.mc | 37 ++++++++++++++++++++++++++++++------- source/TimerDelegate.mc | 17 +++++++++-------- 5 files changed, 39 insertions(+), 28 deletions(-) delete mode 100755 build.sh delete mode 100755 deploy.sh delete mode 100755 run.sh diff --git a/build.sh b/build.sh deleted file mode 100755 index 558d1f3..0000000 --- a/build.sh +++ /dev/null @@ -1,11 +0,0 @@ -monkeyc --warn --output bin/tabata.prg -m manifest.xml \ --z resources/drawables/drawables.xml:\ -resources/layouts/layout.xml:\ -resources/strings/strings.xml \ --d fenix3_sim -u /Users/dsiwiec/connect-iq-sdk-1.2.6/bin/devices.xml \ --p /Users/dsiwiec/connect-iq-sdk-1.2.6/bin/projectInfo.xml \ -source/TabataTimerApp.mc \ -source/Done.mc \ -source/TabataModel.mc \ -source/TimerDelegate.mc \ -source/TimerView.mc diff --git a/deploy.sh b/deploy.sh deleted file mode 100755 index d35cdbf..0000000 --- a/deploy.sh +++ /dev/null @@ -1 +0,0 @@ -./build.sh && cp bin/tabata.prg /Volumes/GARMIN/GARMIN/APPS/ diff --git a/run.sh b/run.sh deleted file mode 100755 index 541cc07..0000000 --- a/run.sh +++ /dev/null @@ -1 +0,0 @@ -./build.sh && connectiq && sleep 3 && monkeydo bin/tabata.prg fenix3 diff --git a/source/TabataModel.mc b/source/TabataModel.mc index 7e587d3..faf5148 100644 --- a/source/TabataModel.mc +++ b/source/TabataModel.mc @@ -11,6 +11,7 @@ class Model{ const PREP_TIME = REST_TIME; const WORK_TIME = REST_TIME * 2; const TOTAL_ROUNDS = 8; + const HAS_TONES = Attention has :playTone; var counter = PREP_TIME; var round = 0; @@ -21,9 +22,12 @@ class Model{ hidden var refreshTimer = new Timer.Timer(); hidden var sensors = Sensor.setEnabledSensors([Sensor.SENSOR_HEARTRATE]); + function initialize(){ + } + function start(){ refreshTimer.start(method(:refresh), 1000, true); - buzz(1000, Attention.TONE_START); + startBuzz(); Ui.requestUpdate(); } @@ -36,20 +40,20 @@ class Model{ phase = :work; counter = WORK_TIME; round++; - buzz(500, Attention.TONE_LOUD_BEEP); + intervalBuzz(); } else if (phase == :work) { phase = :rest; counter = REST_TIME; - buzz(500, Attention.TONE_LOUD_BEEP); + intervalBuzz(); } else if (phase == :rest) { if (round == TOTAL_ROUNDS){ finishUp(); - buzz(1500, Attention.TONE_STOP); + stopBuzz(); } else { phase = :work; counter = WORK_TIME; round++; - buzz(500, Attention.TONE_LOUD_BEEP); + intervalBuzz(); } } } @@ -63,9 +67,28 @@ class Model{ refreshTimer.stop(); } - function buzz(duration, tone){ + function startBuzz(){ + var foo = HAS_TONES && beep(Attention.TONE_LOUD_BEEP); + vibrate(1500); + } + + function stopBuzz(){ + var foo = HAS_TONES && beep(Attention.TONE_LOUD_BEEP); + vibrate(1500); + } + + function intervalBuzz(){ + var foo = HAS_TONES && beep(Attention.TONE_LOUD_BEEP); + vibrate(1000); + } + + function vibrate(duration){ var vibrateData = [ new Attention.VibeProfile( 100, duration ) ]; - Attention.vibrate( vibrateData ); + Attention.vibrate( vibrateData ); + } + + function beep(tone){ Attention.playTone(tone); + return true; } } diff --git a/source/TimerDelegate.mc b/source/TimerDelegate.mc index 3f98b50..c756363 100644 --- a/source/TimerDelegate.mc +++ b/source/TimerDelegate.mc @@ -1,21 +1,22 @@ using Toybox.WatchUi as Ui; -class TimerDelegate extends Ui.BehaviorDelegate { +class TimerDelegate extends Ui.InputDelegate { hidden var model; hidden var started = false; function initialize(mdl) { model = mdl; - BehaviorDelegate.initialize(); + InputDelegate.initialize(); } - function onSelect() { - if (!started){ + function onKey(evt) { + if(evt.getKey() == Ui.KEY_ENTER && !started) { model.start(); started = true; - } - return true; - } - + return true; + } else { + return InputDelegate.onKey(evt); + } + } }