Updated lcars and notanalog to use qalarm

master
David Peer 2022-03-10 22:06:24 +01:00
parent 3a03b8cf7c
commit 0fb271dfef
7 changed files with 25 additions and 77 deletions

View File

@ -16,4 +16,4 @@
0.16: Improved stability. Wind can now be shown. 0.16: Improved stability. Wind can now be shown.
0.17: Settings for mph/kph and other minor improvements. 0.17: Settings for mph/kph and other minor improvements.
0.18: Fullscreen mode can now be enabled or disabled in the settings. 0.18: Fullscreen mode can now be enabled or disabled in the settings.
0.19: Use widtmr for alarm functionality instead of own implementation. 0.19: Use qalarm for alarm functionality instead of own implementation.

View File

@ -1,6 +1,7 @@
const SETTINGS_FILE = "lcars.setting.json"; const SETTINGS_FILE = "lcars.setting.json";
const locale = require('locale'); const locale = require('locale');
const storage = require('Storage') const storage = require('Storage');
const qalarm = require('qalarm');
let settings = { let settings = {
alarm: -1, alarm: -1,
dataRow1: "Steps", dataRow1: "Steps",
@ -563,52 +564,26 @@ function getWeather(){
/* /*
* Handle alarm * Handle alarm
*/ */
function isWidtmrAvailable(){
try {
WIDGETS["widtmr"].isStarted();
return true;
} catch(e) {
// In case the widtmr widget is not installed, the timer can
// not be used...
return false;
}
}
function isAlarmEnabled(){ function isAlarmEnabled(){
if(!isWidtmrAvailable()){ return qalarm.isTimerStarted("lcars");
return false;
}
return WIDGETS["widtmr"].isStarted();
} }
function getAlarmMinutes(){ function getAlarmMinutes(){
if(!isWidtmrAvailable()){ return qalarm.getTimerMin("lcars");
return "-";
}
return WIDGETS["widtmr"].getRemainingMinutes();
} }
function increaseAlarm(){ function increaseAlarm(){
if(!isWidtmrAvailable()){ var mins = qalarm.getTimerMin("lcars")+5;
return; qalarm.deleteTimer("lcars");
} qalarm.editTimer("lcars", 0, mins, 0);
// Set to zero if alarm was disabled before
if(!isAlarmEnabled()){
WIDGETS["widtmr"].setTimer(0);
}
WIDGETS["widtmr"].increaseTimer(5);
WIDGETS["widtmr"].setStarted(true);
} }
function decreaseAlarm(){ function decreaseAlarm(){
if(!isWidtmrAvailable()){ var mins = qalarm.getTimerMin("lcars")-5;
return; qalarm.deleteTimer("lcars");
if(mins > 0){
qalarm.editTimer("lcars", 0, mins, 0);
} }
WIDGETS["widtmr"].decreaseTimer(5);
} }

View File

@ -5,7 +5,7 @@
"icon": "lcars.png", "icon": "lcars.png",
"version":"0.19", "version":"0.19",
"readme": "README.md", "readme": "README.md",
"dependencies": {"widtmr":"app"}, "dependencies": {"qalarm":"app"},
"supports": ["BANGLEJS2"], "supports": ["BANGLEJS2"],
"description": "Library Computer Access Retrieval System (LCARS) clock.", "description": "Library Computer Access Retrieval System (LCARS) clock.",
"type": "clock", "type": "clock",

View File

@ -1,4 +1,4 @@
0.01: Launch app. 0.01: Launch app.
0.02: 12k steps are 360 degrees - improves readability of steps. 0.02: 12k steps are 360 degrees - improves readability of steps.
0.03: Battery improvements through sleep (no minute updates) and partial updates of drawing. 0.03: Battery improvements through sleep (no minute updates) and partial updates of drawing.
0.04: Use widtmr widget for timer instead of own alarm implementation. 0.04: Use qalarm for timer instead of own alarm implementation.

View File

@ -7,7 +7,7 @@
"readme": "README.md", "readme": "README.md",
"supports": ["BANGLEJS2"], "supports": ["BANGLEJS2"],
"description": "An analog watch face for people that can not read analog watch faces.", "description": "An analog watch face for people that can not read analog watch faces.",
"dependencies": {"widtmr":"app"}, "dependencies": {"qalarm":"app"},
"type": "clock", "type": "clock",
"tags": "clock", "tags": "clock",
"screenshots": [ "screenshots": [

View File

@ -5,6 +5,7 @@
const locale = require('locale'); const locale = require('locale');
const storage = require('Storage') const storage = require('Storage')
const SETTINGS_FILE = "notanalog.setting.json"; const SETTINGS_FILE = "notanalog.setting.json";
const qalarm = require('qalarm');
let settings = { let settings = {
alarm: -1, alarm: -1,
}; };
@ -392,52 +393,26 @@ function queueDraw() {
/* /*
* Handle alarm * Handle alarm
*/ */
function isWidtmrAvailable(){
try {
WIDGETS["widtmr"].isStarted();
return true;
} catch(e) {
// In case the widtmr widget is not installed, the timer can
// not be used...
return false;
}
}
function isAlarmEnabled(){ function isAlarmEnabled(){
if(!isWidtmrAvailable()){ return qalarm.isTimerStarted("lcars");
return false;
}
return WIDGETS["widtmr"].isStarted();
} }
function getAlarmMinutes(){ function getAlarmMinutes(){
if(!isWidtmrAvailable()){ return qalarm.getTimerMin("lcars");
return "-";
}
return WIDGETS["widtmr"].getRemainingMinutes();
} }
function increaseAlarm(){ function increaseAlarm(){
if(!isWidtmrAvailable()){ var mins = qalarm.getTimerMin("lcars")+5;
return; qalarm.deleteTimer("lcars");
} qalarm.editTimer("lcars", 0, mins, 0);
// Set to zero if alarm was disabled before
if(!isAlarmEnabled()){
WIDGETS["widtmr"].setTimer(0);
}
WIDGETS["widtmr"].increaseTimer(5);
WIDGETS["widtmr"].setStarted(true);
} }
function decreaseAlarm(){ function decreaseAlarm(){
if(!isWidtmrAvailable()){ var mins = qalarm.getTimerMin("lcars")-5;
return; qalarm.deleteTimer("lcars");
if(mins > 0){
qalarm.editTimer("lcars", 0, mins, 0);
} }
WIDGETS["widtmr"].decreaseTimer(5);
} }
function feedback(){ function feedback(){

View File

@ -1,5 +1,3 @@
Bangle.loadWidgets();
let alarms = require("Storage").readJSON("qalarm.json", 1) || []; let alarms = require("Storage").readJSON("qalarm.json", 1) || [];
/** /**