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;
|
var drawTimeout;
|
||||||
function queueDraw() {
|
function queueDraw() {
|
||||||
|
|
||||||
|
// Faster updates during alarm to ensure that it is
|
||||||
|
// shown correctly...
|
||||||
|
var timeout = isAlarmEnabled() ? 10000 : 60000;
|
||||||
|
|
||||||
if (drawTimeout) clearTimeout(drawTimeout);
|
if (drawTimeout) clearTimeout(drawTimeout);
|
||||||
drawTimeout = setTimeout(function() {
|
drawTimeout = setTimeout(function() {
|
||||||
drawTimeout = undefined;
|
drawTimeout = undefined;
|
||||||
draw();
|
draw();
|
||||||
}, 60000 - (Date.now() % 60000));
|
}, timeout - (Date.now() % timeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -558,18 +563,40 @@ function getWeather(){
|
||||||
/*
|
/*
|
||||||
* Handle alarm
|
* 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(){
|
function isAlarmEnabled(){
|
||||||
|
if(!isWidtmrAvailable()){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return WIDGETS["widtmr"].isStarted();
|
return WIDGETS["widtmr"].isStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAlarmMinutes(){
|
function getAlarmMinutes(){
|
||||||
|
if(!isWidtmrAvailable()){
|
||||||
|
return "-";
|
||||||
|
}
|
||||||
return WIDGETS["widtmr"].getRemainingMinutes();
|
return WIDGETS["widtmr"].getRemainingMinutes();
|
||||||
}
|
}
|
||||||
|
|
||||||
function increaseAlarm(){
|
function increaseAlarm(){
|
||||||
|
if(!isWidtmrAvailable()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Set to zero if alarm was disabled before
|
// Set to zero if alarm was disabled before
|
||||||
if(!isAlarmEnabled()){
|
if(!isAlarmEnabled()){
|
||||||
WIDGETS["widtmr"].resetTimer();
|
WIDGETS["widtmr"].setTime(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
WIDGETS["widtmr"].increaseTimer(5);
|
WIDGETS["widtmr"].increaseTimer(5);
|
||||||
|
|
@ -577,6 +604,10 @@ function increaseAlarm(){
|
||||||
}
|
}
|
||||||
|
|
||||||
function decreaseAlarm(){
|
function decreaseAlarm(){
|
||||||
|
if(!isWidtmrAvailable()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
WIDGETS["widtmr"].decreaseTimer(5);
|
WIDGETS["widtmr"].decreaseTimer(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -376,28 +376,56 @@ Bangle.on('touch', function(btn, e){
|
||||||
* Some helpers
|
* Some helpers
|
||||||
*/
|
*/
|
||||||
function queueDraw() {
|
function queueDraw() {
|
||||||
|
|
||||||
|
// Faster updates during alarm to ensure that it is
|
||||||
|
// shown correctly...
|
||||||
|
var timeout = isAlarmEnabled() ? 10000 : 60000;
|
||||||
|
|
||||||
if (drawTimeout) clearTimeout(drawTimeout);
|
if (drawTimeout) clearTimeout(drawTimeout);
|
||||||
drawTimeout = setTimeout(function() {
|
drawTimeout = setTimeout(function() {
|
||||||
drawTimeout = undefined;
|
drawTimeout = undefined;
|
||||||
draw(true);
|
draw();
|
||||||
}, 60000 - (Date.now() % 60000));
|
}, timeout - (Date.now() % timeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle alarm
|
* 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(){
|
function isAlarmEnabled(){
|
||||||
|
if(!isWidtmrAvailable()){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return WIDGETS["widtmr"].isStarted();
|
return WIDGETS["widtmr"].isStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAlarmMinutes(){
|
function getAlarmMinutes(){
|
||||||
|
if(!isWidtmrAvailable()){
|
||||||
|
return "-";
|
||||||
|
}
|
||||||
return WIDGETS["widtmr"].getRemainingMinutes();
|
return WIDGETS["widtmr"].getRemainingMinutes();
|
||||||
}
|
}
|
||||||
|
|
||||||
function increaseAlarm(){
|
function increaseAlarm(){
|
||||||
|
if(!isWidtmrAvailable()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set to zero if alarm was disabled before
|
||||||
if(!isAlarmEnabled()){
|
if(!isAlarmEnabled()){
|
||||||
WIDGETS["widtmr"].resetTimer();
|
WIDGETS["widtmr"].setTime(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
WIDGETS["widtmr"].increaseTimer(5);
|
WIDGETS["widtmr"].increaseTimer(5);
|
||||||
|
|
@ -405,6 +433,10 @@ function increaseAlarm(){
|
||||||
}
|
}
|
||||||
|
|
||||||
function decreaseAlarm(){
|
function decreaseAlarm(){
|
||||||
|
if(!isWidtmrAvailable()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
WIDGETS["widtmr"].decreaseTimer(5);
|
WIDGETS["widtmr"].decreaseTimer(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ 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
|
- setTime(t) -> void
|
||||||
- increaseTimer(int) -> void
|
- increaseTimer(int) -> void
|
||||||
- decreaseTimer(int) -> void
|
- decreaseTimer(int) -> void
|
||||||
- getRemainingMinutes() -> int
|
- getRemainingMinutes() -> int
|
||||||
|
|
@ -37,7 +37,7 @@ Bangle.loadWidgets();
|
||||||
Bangle.on('touch', function(btn, e){
|
Bangle.on('touch', function(btn, e){
|
||||||
// Set to zero if alarm was disabled before
|
// Set to zero if alarm was disabled before
|
||||||
if(!isAlarmEnabled()){
|
if(!isAlarmEnabled()){
|
||||||
WIDGETS["widtmr"].resetTimer();
|
WIDGETS["widtmr"].setTime(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
WIDGETS["widtmr"].increaseTimer(5);
|
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
|
# Creator
|
||||||
|
|
||||||
[David Peer](https://github.com/peerdavid)
|
[David Peer](https://github.com/peerdavid)
|
||||||
|
|
|
||||||
|
|
@ -121,9 +121,9 @@
|
||||||
}
|
}
|
||||||
updateSettings();
|
updateSettings();
|
||||||
|
|
||||||
}, resetTimer: function(){
|
}, setTime: function(t){
|
||||||
settings.started=false;
|
settings.minutes = Math.max(0, t);
|
||||||
settings.minutes = 0;
|
settings.started = t > 0;
|
||||||
updateSettings();
|
updateSettings();
|
||||||
|
|
||||||
}, getRemainingMinutes: function(){
|
}, getRemainingMinutes: function(){
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue