For watch faces we want to start at 0 rather than the last value that was set...
parent
ef31fd4f01
commit
777943e031
|
|
@ -567,6 +567,11 @@ function getAlarmMinutes(){
|
||||||
}
|
}
|
||||||
|
|
||||||
function increaseAlarm(){
|
function increaseAlarm(){
|
||||||
|
// Set to zero if alarm was disabled before
|
||||||
|
if(!isAlarmEnabled()){
|
||||||
|
WIDGETS["widtmr"].resetTimer();
|
||||||
|
}
|
||||||
|
|
||||||
WIDGETS["widtmr"].increaseTimer(5);
|
WIDGETS["widtmr"].increaseTimer(5);
|
||||||
WIDGETS["widtmr"].setStarted(true);
|
WIDGETS["widtmr"].setStarted(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -396,6 +396,10 @@ function getAlarmMinutes(){
|
||||||
}
|
}
|
||||||
|
|
||||||
function increaseAlarm(){
|
function increaseAlarm(){
|
||||||
|
if(!isAlarmEnabled()){
|
||||||
|
WIDGETS["widtmr"].resetTimer();
|
||||||
|
}
|
||||||
|
|
||||||
WIDGETS["widtmr"].increaseTimer(5);
|
WIDGETS["widtmr"].increaseTimer(5);
|
||||||
WIDGETS["widtmr"].setStarted(true);
|
WIDGETS["widtmr"].setStarted(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,25 +22,36 @@ into your own app.
|
||||||
The following functions are available:
|
The following functions are available:
|
||||||
- isStarted() -> boolean
|
- isStarted() -> boolean
|
||||||
- setStarted(boolean) -> void
|
- setStarted(boolean) -> void
|
||||||
|
- resetTimer() -> void
|
||||||
- increaseTimer(int) -> void
|
- increaseTimer(int) -> void
|
||||||
- decreaseTimer(int) -> void
|
- decreaseTimer(int) -> void
|
||||||
- getRemainingMinutes() -> int
|
- getRemainingMinutes() -> int
|
||||||
- getRemainingTime() -> DateTime
|
- getRemainingTime() -> DateTime
|
||||||
- getRemainingTimeStr() -> str
|
- getRemainingTimeStr() -> str
|
||||||
|
|
||||||
Example to increase the timer by 5 and ensure that its started:
|
For example if we want to increase the timer by +5 minutes each time
|
||||||
|
the touch event is fired:
|
||||||
```Javascript
|
```Javascript
|
||||||
Bangle.loadWidgets();
|
Bangle.loadWidgets();
|
||||||
...
|
...
|
||||||
|
Bangle.on('touch', function(btn, e){
|
||||||
|
// Set to zero if alarm was disabled before
|
||||||
|
if(!isAlarmEnabled()){
|
||||||
|
WIDGETS["widtmr"].resetTimer();
|
||||||
|
}
|
||||||
|
|
||||||
WIDGETS["widtmr"].increaseTimer(5);
|
WIDGETS["widtmr"].increaseTimer(5);
|
||||||
WIDGETS["widtmr"].setStarted(true);
|
WIDGETS["widtmr"].setStarted(true);
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
Example to decrease the timer. This also disables the timer if time <= 0.:
|
Example to decrease the timer by 5 and stop if 0 is reached:
|
||||||
```Javascript
|
```Javascript
|
||||||
Bangle.loadWidgets();
|
Bangle.loadWidgets();
|
||||||
...
|
...
|
||||||
|
Bangle.on('touch', function(btn, e){
|
||||||
WIDGETS["widtmr"].decreaseTimer(5);
|
WIDGETS["widtmr"].decreaseTimer(5);
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
# Creator
|
# Creator
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,11 @@
|
||||||
}
|
}
|
||||||
updateSettings();
|
updateSettings();
|
||||||
|
|
||||||
|
}, resetTimer: function(){
|
||||||
|
settings.started=false;
|
||||||
|
settings.minutes = 0;
|
||||||
|
updateSettings();
|
||||||
|
|
||||||
}, getRemainingMinutes: function(){
|
}, getRemainingMinutes: function(){
|
||||||
settings = storage.readJSON("widtmr.json",1)||{started: false};
|
settings = storage.readJSON("widtmr.json",1)||{started: false};
|
||||||
if(!settings.started){
|
if(!settings.started){
|
||||||
|
|
@ -129,7 +134,7 @@
|
||||||
|
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
var diff = settings.goal - now;
|
var diff = settings.goal - now;
|
||||||
return Math.ceil(diff / (1000*60));
|
return Math.round(diff / (1000*60));
|
||||||
|
|
||||||
}, getRemainingTimeStr: function(){
|
}, getRemainingTimeStr: function(){
|
||||||
settings = storage.readJSON("widtmr.json",1)||{started: false};
|
settings = storage.readJSON("widtmr.json",1)||{started: false};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue