Updated lcars and notanalog to also work if the widget is not installed. Then this functionality is not provided but the apps are not crashing. Also faster updates of the watch face in timer mode to show the correct time...
parent
777943e031
commit
3bbbd8831c
|
|
@ -124,11 +124,16 @@ Graphics.prototype.setFontAntonioLarge = function(scale) {
|
|||
*/
|
||||
var drawTimeout;
|
||||
function queueDraw() {
|
||||
|
||||
// Faster updates during alarm to ensure that it is
|
||||
// shown correctly...
|
||||
var timeout = isAlarmEnabled() ? 10000 : 60000;
|
||||
|
||||
if (drawTimeout) clearTimeout(drawTimeout);
|
||||
drawTimeout = setTimeout(function() {
|
||||
drawTimeout = undefined;
|
||||
draw();
|
||||
}, 60000 - (Date.now() % 60000));
|
||||
}, timeout - (Date.now() % timeout));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -558,18 +563,40 @@ function getWeather(){
|
|||
/*
|
||||
* Handle alarm
|
||||
*/
|
||||
function isWidtmrAvailable(){
|
||||
try {
|
||||
WIDGETS["widtmr"].isStarted();
|
||||
return true;
|
||||
} catch {
|
||||
// In case the widtmr widget is not installed, the timer can
|
||||
// not be used...
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isAlarmEnabled(){
|
||||
if(!isWidtmrAvailable()){
|
||||
return false;
|
||||
}
|
||||
|
||||
return WIDGETS["widtmr"].isStarted();
|
||||
}
|
||||
|
||||
function getAlarmMinutes(){
|
||||
if(!isWidtmrAvailable()){
|
||||
return "-";
|
||||
}
|
||||
return WIDGETS["widtmr"].getRemainingMinutes();
|
||||
}
|
||||
|
||||
function increaseAlarm(){
|
||||
if(!isWidtmrAvailable()){
|
||||
return;
|
||||
}
|
||||
|
||||
// Set to zero if alarm was disabled before
|
||||
if(!isAlarmEnabled()){
|
||||
WIDGETS["widtmr"].resetTimer();
|
||||
WIDGETS["widtmr"].setTime(0);
|
||||
}
|
||||
|
||||
WIDGETS["widtmr"].increaseTimer(5);
|
||||
|
|
@ -577,6 +604,10 @@ function increaseAlarm(){
|
|||
}
|
||||
|
||||
function decreaseAlarm(){
|
||||
if(!isWidtmrAvailable()){
|
||||
return;
|
||||
}
|
||||
|
||||
WIDGETS["widtmr"].decreaseTimer(5);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -376,28 +376,56 @@ Bangle.on('touch', function(btn, e){
|
|||
* Some helpers
|
||||
*/
|
||||
function queueDraw() {
|
||||
|
||||
// Faster updates during alarm to ensure that it is
|
||||
// shown correctly...
|
||||
var timeout = isAlarmEnabled() ? 10000 : 60000;
|
||||
|
||||
if (drawTimeout) clearTimeout(drawTimeout);
|
||||
drawTimeout = setTimeout(function() {
|
||||
drawTimeout = undefined;
|
||||
draw(true);
|
||||
}, 60000 - (Date.now() % 60000));
|
||||
draw();
|
||||
}, timeout - (Date.now() % timeout));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Handle alarm
|
||||
*/
|
||||
function isWidtmrAvailable(){
|
||||
try {
|
||||
WIDGETS["widtmr"].isStarted();
|
||||
return true;
|
||||
} catch {
|
||||
// In case the widtmr widget is not installed, the timer can
|
||||
// not be used...
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isAlarmEnabled(){
|
||||
if(!isWidtmrAvailable()){
|
||||
return false;
|
||||
}
|
||||
|
||||
return WIDGETS["widtmr"].isStarted();
|
||||
}
|
||||
|
||||
function getAlarmMinutes(){
|
||||
if(!isWidtmrAvailable()){
|
||||
return "-";
|
||||
}
|
||||
return WIDGETS["widtmr"].getRemainingMinutes();
|
||||
}
|
||||
|
||||
function increaseAlarm(){
|
||||
if(!isWidtmrAvailable()){
|
||||
return;
|
||||
}
|
||||
|
||||
// Set to zero if alarm was disabled before
|
||||
if(!isAlarmEnabled()){
|
||||
WIDGETS["widtmr"].resetTimer();
|
||||
WIDGETS["widtmr"].setTime(0);
|
||||
}
|
||||
|
||||
WIDGETS["widtmr"].increaseTimer(5);
|
||||
|
|
@ -405,6 +433,10 @@ function increaseAlarm(){
|
|||
}
|
||||
|
||||
function decreaseAlarm(){
|
||||
if(!isWidtmrAvailable()){
|
||||
return;
|
||||
}
|
||||
|
||||
WIDGETS["widtmr"].decreaseTimer(5);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ into your own app.
|
|||
The following functions are available:
|
||||
- isStarted() -> boolean
|
||||
- setStarted(boolean) -> void
|
||||
- resetTimer() -> void
|
||||
- setTime(t) -> void
|
||||
- increaseTimer(int) -> void
|
||||
- decreaseTimer(int) -> void
|
||||
- getRemainingMinutes() -> int
|
||||
|
|
@ -37,7 +37,7 @@ Bangle.loadWidgets();
|
|||
Bangle.on('touch', function(btn, e){
|
||||
// Set to zero if alarm was disabled before
|
||||
if(!isAlarmEnabled()){
|
||||
WIDGETS["widtmr"].resetTimer();
|
||||
WIDGETS["widtmr"].setTime(0);
|
||||
}
|
||||
|
||||
WIDGETS["widtmr"].increaseTimer(5);
|
||||
|
|
@ -54,6 +54,8 @@ Bangle.on('touch', function(btn, e){
|
|||
}
|
||||
```
|
||||
|
||||
You can find even more examples in the lcars or notanalog app ...
|
||||
|
||||
# Creator
|
||||
|
||||
[David Peer](https://github.com/peerdavid)
|
||||
|
|
|
|||
|
|
@ -121,9 +121,9 @@
|
|||
}
|
||||
updateSettings();
|
||||
|
||||
}, resetTimer: function(){
|
||||
settings.started=false;
|
||||
settings.minutes = 0;
|
||||
}, setTime: function(t){
|
||||
settings.minutes = Math.max(0, t);
|
||||
settings.started = t > 0;
|
||||
updateSettings();
|
||||
|
||||
}, getRemainingMinutes: function(){
|
||||
|
|
|
|||
Loading…
Reference in New Issue