Skip to content

Commit

Permalink
Turn beeps off for vivoactive
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsiwiec committed May 16, 2016
1 parent 1dac3bd commit daf4aac
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 28 deletions.
11 changes: 0 additions & 11 deletions build.sh

This file was deleted.

1 change: 0 additions & 1 deletion deploy.sh

This file was deleted.

1 change: 0 additions & 1 deletion run.sh

This file was deleted.

37 changes: 30 additions & 7 deletions source/TabataModel.mc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}

Expand All @@ -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();
}
}
}
Expand All @@ -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;
}
}
17 changes: 9 additions & 8 deletions source/TimerDelegate.mc
Original file line number Diff line number Diff line change
@@ -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);
}
}
}

0 comments on commit daf4aac

Please sign in to comment.