Merge branch 'espruino:master' into master
|
@ -10,3 +10,4 @@
|
|||
0.09: Alarm vibration, repeat, and auto-snooze now handled by sched
|
||||
0.10: Fix SMS bug
|
||||
0.12: Use default Bangle formatter for booleans
|
||||
0.13: Added Bangle.http function (see Readme file for more info)
|
||||
|
|
|
@ -32,6 +32,25 @@ Responses are sent back to Gadgetbridge simply as one line of JSON.
|
|||
|
||||
More info on message formats on http://www.espruino.com/Gadgetbridge
|
||||
|
||||
## Functions provided
|
||||
|
||||
The boot code also provides some useful functions:
|
||||
|
||||
* `Bangle.messageResponse = function(msg,response)` - send a yes/no response to a message. `msg` is a message object, and `response` is a boolean.
|
||||
* `Bangle.musicControl = function(cmd)` - control music, cmd = `play/pause/next/previous/volumeup/volumedown`
|
||||
* `Bangle.http = function(url,options)` - make an HTTPS request to a URL and return a promise with the data. Requires the [internet enabled `Bangle.js Gadgetbridge` app](http://www.espruino.com/Gadgetbridge#http-requests). `options` can contain:
|
||||
* `id` - a custom (string) ID
|
||||
* `timeout` - a timeout for the request in milliseconds (default 30000ms)
|
||||
* `xpath` an xPath query to run on the request (but right now the URL requested must be XML - HTML is rarely XML compliant)
|
||||
|
||||
eg:
|
||||
|
||||
```
|
||||
Bangle.http("https://pur3.co.uk/hello.txt").then(data=>{
|
||||
console.log("Got ",data);
|
||||
});
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
Bangle.js can only hold one connection open at a time, so it's hard to see
|
||||
|
|
|
@ -118,11 +118,50 @@
|
|||
var cal = require("Storage").readJSON("android.calendar.json",true);
|
||||
if (!cal || !Array.isArray(cal)) cal = [];
|
||||
gbSend({t:"force_calendar_sync", ids: cal.map(e=>e.id)});
|
||||
},
|
||||
"http":function() {
|
||||
//get the promise and call the promise resolve
|
||||
if (Bangle.httpRequest === undefined) return;
|
||||
var objID=Bangle.httpRequest[event.id];
|
||||
if (objID === undefined) return; //already timedout or wrong id
|
||||
delete Bangle.httpRequest[event.id];
|
||||
clearInterval(objID.t); //t = timeout variable
|
||||
if(event.err!==undefined) //if is error
|
||||
objID.j(event.err); //r = reJect function
|
||||
else
|
||||
objID.r(event); //r = resolve function
|
||||
}
|
||||
};
|
||||
var h = HANDLERS[event.t];
|
||||
if (h) h(); else console.log("GB Unknown",event);
|
||||
};
|
||||
// HTTP request handling - see the readme
|
||||
// options = {id,timeout,xpath}
|
||||
Bangle.http = (url,options)=>{
|
||||
options = options||{};
|
||||
if (Bangle.httpRequest === undefined)
|
||||
Bangle.httpRequest={};
|
||||
if (options.id === undefined) {
|
||||
// try and create a unique ID
|
||||
do {
|
||||
options.id = Math.random().toString().substr(2);
|
||||
} while( Bangle.httpRequest[options.id]!==undefined);
|
||||
}
|
||||
//send the request
|
||||
var req = {t: "http", url:url, id:options.id};
|
||||
if (options.xpath) req.xpath = options.xpath;
|
||||
gbSend(req);
|
||||
//create the promise
|
||||
var promise = new Promise(function(resolve,reject) {
|
||||
//save the resolve function in the dictionary and create a timeout (30 seconds default)
|
||||
Bangle.httpRequest[options.id]={r:resolve,j:reject,t:setTimeout(()=>{
|
||||
//if after "timeoutMillisec" it still hasn't answered -> reject
|
||||
delete Bangle.httpRequest[options.id];
|
||||
reject("Timeout");
|
||||
},options.timeout||30000)};
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
|
||||
// Battery monitor
|
||||
function sendBattery() { gbSend({ t: "status", bat: E.getBattery(), chg: Bangle.isCharging()?1:0 }); }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"id": "android",
|
||||
"name": "Android Integration",
|
||||
"shortName": "Android",
|
||||
"version": "0.12",
|
||||
"version": "0.13",
|
||||
"description": "Display notifications/music/etc sent from the Gadgetbridge app on Android. This replaces the old 'Gadgetbridge' Bangle.js widget.",
|
||||
"icon": "app.png",
|
||||
"tags": "tool,system,messages,notifications,gadgetbridge",
|
||||
|
|
|
@ -23,3 +23,5 @@
|
|||
0.08: Allow scanning for devices in settings
|
||||
0.09: Misc Fixes and improvements (https://github.com/espruino/BangleApps/pull/1655)
|
||||
0.10: Use default Bangle formatter for booleans
|
||||
0.11: App now shows status info while connecting
|
||||
Fixes to allow cached BluetoothRemoteGATTCharacteristic to work with 2v14.14 onwards (>1 central)
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
);
|
||||
|
||||
var log = function(text, param){
|
||||
if (global.showStatusInfo)
|
||||
showStatusInfo(text)
|
||||
if (settings.debuglog){
|
||||
var logline = new Date().toISOString() + " - " + text;
|
||||
if (param){
|
||||
logline += " " + JSON.stringify(param);
|
||||
}
|
||||
if (param) logline += ": " + JSON.stringify(param);
|
||||
print(logline);
|
||||
}
|
||||
};
|
||||
|
@ -30,7 +30,7 @@
|
|||
};
|
||||
|
||||
var addNotificationHandler = function(characteristic) {
|
||||
log("Setting notification handler: " + supportedCharacteristics[characteristic.uuid].handler);
|
||||
log("Setting notification handler"/*supportedCharacteristics[characteristic.uuid].handler*/);
|
||||
characteristic.on('characteristicvaluechanged', (ev) => supportedCharacteristics[characteristic.uuid].handler(ev.target.value));
|
||||
};
|
||||
|
||||
|
@ -61,7 +61,8 @@
|
|||
writeCache(cache);
|
||||
};
|
||||
|
||||
var characteristicsFromCache = function() {
|
||||
var characteristicsFromCache = function(device) {
|
||||
var service = { device : device }; // fake a BluetoothRemoteGATTService
|
||||
log("Read cached characteristics");
|
||||
var cache = getCache();
|
||||
if (!cache.characteristics) return [];
|
||||
|
@ -75,6 +76,7 @@
|
|||
r.properties = {};
|
||||
r.properties.notify = cached.notify;
|
||||
r.properties.read = cached.read;
|
||||
r.service = service;
|
||||
addNotificationHandler(r);
|
||||
log("Restored characteristic: ", r);
|
||||
restored.push(r);
|
||||
|
@ -141,7 +143,7 @@
|
|||
src: "bthrm"
|
||||
};
|
||||
|
||||
log("Emitting HRM: ", repEvent);
|
||||
log("Emitting HRM", repEvent);
|
||||
Bangle.emit("HRM", repEvent);
|
||||
}
|
||||
|
||||
|
@ -155,7 +157,7 @@
|
|||
if (battery) newEvent.battery = battery;
|
||||
if (sensorContact) newEvent.contact = sensorContact;
|
||||
|
||||
log("Emitting BTHRM: ", newEvent);
|
||||
log("Emitting BTHRM", newEvent);
|
||||
Bangle.emit("BTHRM", newEvent);
|
||||
}
|
||||
},
|
||||
|
@ -236,8 +238,8 @@
|
|||
if (!currentRetryTimeout){
|
||||
|
||||
var clampedTime = retryTime < 100 ? 100 : retryTime;
|
||||
|
||||
log("Set timeout for retry as " + clampedTime);
|
||||
|
||||
log("Set timeout for retry as " + clampedTime);
|
||||
clearRetryTimeout();
|
||||
currentRetryTimeout = setTimeout(() => {
|
||||
log("Retrying");
|
||||
|
@ -257,8 +259,8 @@
|
|||
var buzzing = false;
|
||||
var onDisconnect = function(reason) {
|
||||
log("Disconnect: " + reason);
|
||||
log("GATT: ", gatt);
|
||||
log("Characteristics: ", characteristics);
|
||||
log("GATT", gatt);
|
||||
log("Characteristics", characteristics);
|
||||
retryTime = initialRetryTime;
|
||||
clearRetryTimeout();
|
||||
switchInternalHrm();
|
||||
|
@ -273,13 +275,13 @@
|
|||
};
|
||||
|
||||
var createCharacteristicPromise = function(newCharacteristic) {
|
||||
log("Create characteristic promise: ", newCharacteristic);
|
||||
log("Create characteristic promise", newCharacteristic);
|
||||
var result = Promise.resolve();
|
||||
// For values that can be read, go ahead and read them, even if we might be notified in the future
|
||||
// Allows for getting initial state of infrequently updating characteristics, like battery
|
||||
if (newCharacteristic.readValue){
|
||||
result = result.then(()=>{
|
||||
log("Reading data for " + JSON.stringify(newCharacteristic));
|
||||
log("Reading data", newCharacteristic);
|
||||
return newCharacteristic.readValue().then((data)=>{
|
||||
if (supportedCharacteristics[newCharacteristic.uuid] && supportedCharacteristics[newCharacteristic.uuid].handler) {
|
||||
supportedCharacteristics[newCharacteristic.uuid].handler(data);
|
||||
|
@ -289,8 +291,8 @@
|
|||
}
|
||||
if (newCharacteristic.properties.notify){
|
||||
result = result.then(()=>{
|
||||
log("Starting notifications for: ", newCharacteristic);
|
||||
var startPromise = newCharacteristic.startNotifications().then(()=>log("Notifications started for ", newCharacteristic));
|
||||
log("Starting notifications", newCharacteristic);
|
||||
var startPromise = newCharacteristic.startNotifications().then(()=>log("Notifications started", newCharacteristic));
|
||||
if (settings.gracePeriodNotification > 0){
|
||||
log("Add " + settings.gracePeriodNotification + "ms grace period after starting notifications");
|
||||
startPromise = startPromise.then(()=>{
|
||||
|
@ -301,7 +303,7 @@
|
|||
return startPromise;
|
||||
});
|
||||
}
|
||||
return result.then(()=>log("Handled characteristic: ", newCharacteristic));
|
||||
return result.then(()=>log("Handled characteristic", newCharacteristic));
|
||||
};
|
||||
|
||||
var attachCharacteristicPromise = function(promise, characteristic) {
|
||||
|
@ -312,11 +314,11 @@
|
|||
};
|
||||
|
||||
var createCharacteristicsPromise = function(newCharacteristics) {
|
||||
log("Create characteristics promise: ", newCharacteristics);
|
||||
log("Create characteristics promis ", newCharacteristics);
|
||||
var result = Promise.resolve();
|
||||
for (var c of newCharacteristics){
|
||||
if (!supportedCharacteristics[c.uuid]) continue;
|
||||
log("Supporting characteristic: ", c);
|
||||
log("Supporting characteristic", c);
|
||||
characteristics.push(c);
|
||||
if (c.properties.notify){
|
||||
addNotificationHandler(c);
|
||||
|
@ -328,10 +330,10 @@
|
|||
};
|
||||
|
||||
var createServicePromise = function(service) {
|
||||
log("Create service promise: ", service);
|
||||
log("Create service promise", service);
|
||||
var result = Promise.resolve();
|
||||
result = result.then(()=>{
|
||||
log("Handling service: " + service.uuid);
|
||||
log("Handling service" + service.uuid);
|
||||
return service.getCharacteristics().then((c)=>createCharacteristicsPromise(c));
|
||||
});
|
||||
return result.then(()=>log("Handled service" + service.uuid));
|
||||
|
@ -368,7 +370,7 @@
|
|||
}
|
||||
|
||||
promise = promise.then((d)=>{
|
||||
log("Got device: ", d);
|
||||
log("Got device", d);
|
||||
d.on('gattserverdisconnected', onDisconnect);
|
||||
device = d;
|
||||
});
|
||||
|
@ -379,14 +381,14 @@
|
|||
});
|
||||
} else {
|
||||
promise = Promise.resolve();
|
||||
log("Reuse device: ", device);
|
||||
log("Reuse device", device);
|
||||
}
|
||||
|
||||
promise = promise.then(()=>{
|
||||
if (gatt){
|
||||
log("Reuse GATT: ", gatt);
|
||||
log("Reuse GATT", gatt);
|
||||
} else {
|
||||
log("GATT is new: ", gatt);
|
||||
log("GATT is new", gatt);
|
||||
characteristics = [];
|
||||
var cachedId = getCache().id;
|
||||
if (device.id !== cachedId){
|
||||
|
@ -404,7 +406,10 @@
|
|||
|
||||
promise = promise.then((gatt)=>{
|
||||
if (!gatt.connected){
|
||||
var connectPromise = gatt.connect(connectSettings);
|
||||
log("Connecting...");
|
||||
var connectPromise = gatt.connect(connectSettings).then(function() {
|
||||
log("Connected.");
|
||||
});
|
||||
if (settings.gracePeriodConnect > 0){
|
||||
log("Add " + settings.gracePeriodConnect + "ms grace period after connecting");
|
||||
connectPromise = connectPromise.then(()=>{
|
||||
|
@ -432,7 +437,7 @@
|
|||
|
||||
promise = promise.then(()=>{
|
||||
if (!characteristics || characteristics.length === 0){
|
||||
characteristics = characteristicsFromCache();
|
||||
characteristics = characteristicsFromCache(device);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -445,11 +450,11 @@
|
|||
});
|
||||
|
||||
characteristicsPromise = characteristicsPromise.then((services)=>{
|
||||
log("Got services:", services);
|
||||
log("Got services", services);
|
||||
var result = Promise.resolve();
|
||||
for (var service of services){
|
||||
if (!(supportedServices.includes(service.uuid))) continue;
|
||||
log("Supporting service: ", service.uuid);
|
||||
log("Supporting service", service.uuid);
|
||||
result = attachServicePromise(result, service);
|
||||
}
|
||||
if (settings.gracePeriodService > 0) {
|
||||
|
@ -496,7 +501,7 @@
|
|||
log("Power off for " + app);
|
||||
if (gatt) {
|
||||
if (gatt.connected){
|
||||
log("Disconnect with gatt: ", gatt);
|
||||
log("Disconnect with gatt", gatt);
|
||||
try{
|
||||
gatt.disconnect().then(()=>{
|
||||
log("Successful disconnect");
|
||||
|
|
|
@ -42,12 +42,20 @@ function draw(y, type, event) {
|
|||
if (event.energy) str += " kJoule: " + event.energy.toFixed(0);
|
||||
g.setFontVector(12).drawString(str,px,y+60);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var firstEventBt = true;
|
||||
var firstEventInt = true;
|
||||
|
||||
|
||||
// This can get called for the boot code to show what's happening
|
||||
function showStatusInfo(txt) {
|
||||
var R = Bangle.appRect;
|
||||
g.reset().clearRect(R.x,R.y2-8,R.x2,R.y2).setFont("6x8");
|
||||
txt = g.wrapString(txt, R.w)[0];
|
||||
g.setFontAlign(0,1).drawString(txt, (R.x+R.x2)/2, R.y2);
|
||||
}
|
||||
|
||||
function onBtHrm(e) {
|
||||
if (firstEventBt){
|
||||
clear(24);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"id": "bthrm",
|
||||
"name": "Bluetooth Heart Rate Monitor",
|
||||
"shortName": "BT HRM",
|
||||
"version": "0.10",
|
||||
"version": "0.11",
|
||||
"description": "Overrides Bangle.js's build in heart rate monitor with an external Bluetooth one.",
|
||||
"icon": "app.png",
|
||||
"type": "app",
|
||||
|
|
|
@ -8,4 +8,5 @@
|
|||
0.08: Select the color of widgets correctly. Additional settings to hide colon.
|
||||
0.09: Larger font size if colon is hidden to improve readability further.
|
||||
0.10: HomeAssistant integration if HomeAssistant is installed.
|
||||
0.11: Performance improvements.
|
||||
0.11: Performance improvements.
|
||||
0.12: Implements a 2D menu.
|
|
@ -1,18 +1,44 @@
|
|||
# BW Clock
|
||||
A very minimalistic clock with date and time in focus.
|
||||
|
||||

|
||||
|
||||
## Features
|
||||
- Fullscreen on/off
|
||||
- Tab left/right of screen to show steps, temperature etc.
|
||||
- Enable / disable lock icon in the settings.
|
||||
- If the "sched" app is installed tab top / bottom of the screen to set the timer.
|
||||
- If HomeAssistant is installed, triggers are shown. Simple select the trigger and touch the middle of the screen to send the trigger to HomeAssistant.
|
||||
- The design is adapted to the theme of your bangle.
|
||||
- The colon (e.g. 7:35 = 735) can be hidden now in the settings.
|
||||
The BW clock provides many features as well as 3rd party integrations:
|
||||
- Bangle data such as steps, heart rate, battery or charging state.
|
||||
- A timer can be set directly. *Requirement: Scheduler library*
|
||||
- Weather temperature as well as the wind speed can be shown. *Requirement: Weather app*
|
||||
- HomeAssistant triggers can be executed directly. *Requirement: HomeAssistant app*
|
||||
|
||||
Note: If some apps are not installed (e.gt. weather app), then this menu item is hidden.
|
||||
|
||||
## Menu
|
||||
2D menu allows you to display lots of different data including data from 3rd party apps and it's also possible to control things e.g. to set a timer or send a HomeAssistant trigger.
|
||||
|
||||
Simply click left / right to go through the menu entries such as Bangle, Timer etc.
|
||||
and click up/down to move into this sub-menu. You can then click in the middle of the screen
|
||||
to e.g. send a trigger via HomeAssistant once you selected it.
|
||||
|
||||
```
|
||||
Bpm ...
|
||||
| |
|
||||
Steps 10 min. ... ...
|
||||
| | | |
|
||||
Battery 5 min Temp. Trigger1
|
||||
| | | |
|
||||
Bangle -- Timer[Optional] -- Weather[Optional] -- HomeAssistant [Optional]
|
||||
```
|
||||
|
||||
## Settings
|
||||
- Fullscreen on/off (widgets are still loaded).
|
||||
- Enable/disable lock icon in the settings. Useful if fullscreen is on.
|
||||
- The colon (e.g. 7:35 = 735) can be hidden in the settings for an even larger time font to improve readability further.
|
||||
- There are no design settings, as your bangle sys settings are used.
|
||||
|
||||
|
||||
## Thanks to
|
||||
<a href="https://www.flaticon.com/free-icons/" title="Icons">Icons created by Flaticon</a>
|
||||
|
||||
|
||||
## Creator
|
||||
- [David Peer](https://github.com/peerdavid)
|
||||
[David Peer](https://github.com/peerdavid)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
/************
|
||||
* Includes
|
||||
*/
|
||||
const locale = require('locale');
|
||||
const storage = require('Storage');
|
||||
|
||||
/*
|
||||
/************
|
||||
* Statics
|
||||
*/
|
||||
const SETTINGS_FILE = "bwclk.setting.json";
|
||||
|
@ -12,14 +12,15 @@ const TIMER_IDX = "bwclk";
|
|||
const W = g.getWidth();
|
||||
const H = g.getHeight();
|
||||
|
||||
/*
|
||||
/************
|
||||
* Settings
|
||||
*/
|
||||
let settings = {
|
||||
fullscreen: false,
|
||||
showLock: true,
|
||||
hideColon: false,
|
||||
showInfo: 0,
|
||||
menuPosX: 0,
|
||||
menuPosY: 0,
|
||||
};
|
||||
|
||||
let saved_settings = storage.readJSON(SETTINGS_FILE, 1) || settings;
|
||||
|
@ -28,22 +29,10 @@ for (const key in saved_settings) {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
/************
|
||||
* Assets
|
||||
*/
|
||||
|
||||
// Manrope font
|
||||
Graphics.prototype.setLargeFont = function(scale) {
|
||||
// Actual height 48 (49 - 2)
|
||||
this.setFontCustom(
|
||||
E.toString(require('heatshrink').decompress(atob('AFcH+AHFh/gA4sf4AHFn+AA4t/E43+AwsB/gHFgf4PH4AMgJ9Ngf/Pot//6bF/59F///PokfA4J9DEgIABEwYkB/7DDEgIlFCoRMDEgQsEDoRLEEgpoBA4JhGOIsHZ40PdwwA/L4SjHNAgGCP4cHA4wWDA4aVCA4gGDA4SNBe4IiBA4MPHYRBBEwScCA4d/EQUBaoRKDA4UBLQYECgb+EAgMHYYcHa4MPHoLBCBgMfYgcfBgM/PIc/BgN/A4YECIIQEDHwkDHwQHDGwQHENQUHA4d/QIQnCRIJJCSgYTCA4hqCA4hqCA4hiCA4ZCEA4RFBGYbrFAHxDGSohdDcgagFAAjPCEzicDToU/A4jPCAwbQCBwgrBgIHEFYKrDWoa7DaggA/AC0PAYV+AYSBCgKpCg4DDVIUfAYZ9BToIDDPoKVBAYfARoQDDXgMPFwTIBdYSYCv4LCv7zCXgYKCXAK8CHoUPXgY9Cn/vEYMPEwX/z46Bj4mBgf+n77CDwX4v54EIIIzCOgX/4I+CAQI9BHYQCCQ4I7CRASDBHYQHCv/Aj4+BGYIeBGAI+Bj/8AIIRBQIZjCRIiWBXgYHCPQgHBBgJ6DA4IEBPQaKBGYQ+BbgiCCAGZFDIIUBaAZBCgYHCQAQTBA4SACUwS8DDYQHBQAbVCQAYwBA4SABgYEBPoQCBFgU/CQWACgRDCHwKVCIYX+aYRDCHwMPAgY+Cn4EDHwX/AgY+B8bEFj/HA4RGCn+f94MBv45Cv+fA4J6C//+j5gBGIMBFoJWBQoRMB8E//4DBHIJcBv4HBEwJUCA4ImCj5MBA4KZCPYQHBZgRBCE4LICvwaCXAYA5PgQAEMIQAEUwQADQAJlCAARlBWYIACT4JtDAAMPA4IWESgg8CAwI+EEoPhHwYlCgY+DEoP4g4+DEoPAh4+CEoReBHwUfLYU/CwgMBXARqBHYQCCGoIjBgI+CgZSCHwcHAYY+Ch4lBJ4IbCjhACPwqUBPwqFCPwhQBIQZ+DOAKVFXooHCXop9DFAi8EFAT0GPoYAygwFEgOATISLDwBWDTQc/A4L6CTQKkCVQX+BYIHBDwX+BYIHBVQX8B4KqD+/wA4aBBj/AgK8CQIIJBA4a/BBIMBAgL/BAgUDYgL/BAII7BAQXgAII7BAQXAYQQxBYARrCMwQ0BAgV/HwYECHwgEBgY+EA4MPGwI8BA4UfGwI8BgYHBPofAQYOHPoeAR4QmBHwQHCEwI+CA4RVBHwQHCaggnBDwQHEHoIAEEQIA6v5NFfgSECBwZtEf4IHFOYQHEj4HGDwYHCDwPgv/jA4UHXQS8E/ED/AHDZ4MPSYKlCv+AYwIHDDwL7EgL7DAgTzCEwIpCeYTZBg4CBeYIJBAgICBFgIJBAgICBeYIEDHII0BAgg+EgI5CMocHGwJBCA4MfGwMD/h/BwF/PoQHC451CJIMDSgIjBA4PAA4QmBA4IhBA4JVBgEMA4bUDV4QeCAAf/HoIAENIIApOoIAEW4QAEW4QAEW4QAEWQRSFNIcDfYQMDny8DO4Q7BAQQjCewh+EHwcPToQ+Dv//ewkHUoI+En68DeIS0EHwMf/46CeYYlCHwQ0BKIY+BGgJ4Dh/nGgZZCAwKPEHYLpFDoKuFGgj4JgY0EHwQ0EYhIA6MAkf+BRBLIa5BQAJSCBgP4R4iVB/YHERoIACA4QGDE4SFBAoV/A4MH/ggBWIL7C8EfVoL4DwBHBFYIHBfYIRBAgT7CDgQEBgP4BgUBEIMDDgIMBgYMBg/gBgS5Ch/ABgUPFIMf4EHA4IEBHwUPCgJGCIIM/CgLgCAQJlBFIQFB44HBEIUBQYc/EIIHDAAIuBA4oeBRoSfBLAIHC/gHBEwIXC+AHBZghHBDwQADj4WCAHEPAwpWBKYYOCLwIHELYJUBghlDA4UcQogHBvgeDD4K0DDwIHBWgQeB4CyBh68CUAMf8DeCdIYHDdIfAfYjxCAgj2BAgbHCvwJCIIYCBBIMDHIX4BgUHFwMD+AMCA4Q0BAgg5CHwxICAQY5BdgQHBEgMDIYV/DgR1CA4PwP4KvDRgIACEYIHFWggABMQQHEZwd/Dwq1DHoTFEdooA/ACrBBcAZmC8DTCAATGBaYR+DwDTCRwbYDAASLBCIIGCFgQRBAG4='))),
|
||||
46,
|
||||
atob("EhooGyUkJiUnISYnFQ=="),
|
||||
63+(scale<<8)+(1<<16)
|
||||
);
|
||||
return this;
|
||||
};
|
||||
|
||||
Graphics.prototype.setXLargeFont = function(scale) {
|
||||
// Actual height 53 (55 - 3)
|
||||
this.setFontCustom(
|
||||
|
@ -54,12 +43,26 @@ Graphics.prototype.setXLargeFont = function(scale) {
|
|||
);
|
||||
};
|
||||
|
||||
|
||||
Graphics.prototype.setLargeFont = function(scale) {
|
||||
// Actual height 47 (48 - 2)
|
||||
this.setFontCustom(
|
||||
atob('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8AAAAAAAAD/AAAAAAAAA/wAAAAAAAAP8AAAAAAAAD/AAAAAAAAA/wAAAAAAAAP8AAAAAAAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAD/AAAAAAAAP/wAAAAAAAf/8AAAAAAB///AAAAAAH///wAAAAAf///8AAAAB/////AAAAH////8AAAAP////wAAAA/////AAAAB////+AAAAA////4AAAAAP///gAAAAAD//+AAAAAAA//4AAAAAAAP/gAAAAAAAD/AAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA///+AAAAAB////8AAAAB/////wAAAA/////+AAAA//////wAAAf/////+AAAH//////wAAD//////+AAB/+AAAf/gAAf+AAAA/8AAH/AAAAH/AAD/gAAAA/4AA/wAAAAH+AAP8AAAAB/gAD+AAAAAf4AA/gAAAAH+AAP4AAAAA/gAD+AAAAAf4AA/wAAAAH+AAP8AAAAB/gAD/AAAAA/4AA/4AAAAP+AAH/AAAAH/AAB/4AAAH/wAAP/wAAP/4AAD//////+AAAf//////AAAD//////gAAAf/////wAAAD/////4AAAAf////4AAAAB////4AAAAAB///gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8AAAAAAAAH/AAAAAAAAD/gAAAAAAAA/4AAAAAAAAf8AAAAAAAAH+AAAAAAAAD/gAAAAAAAB/wAAAAAAAAf8AAAAAAAAP///////AAD///////wAA///////8AAP///////AAD///////wAA///////8AAP///////AAD///////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+AAAB/AAAA/gAAA/wAAA/4AAAf8AAAf+AAAP/AAAP/gAAH/wAAH/4AAD/8AAD/+AAB//AAA//gAA//wAAf/AAAP/8AAH/AAAH//AAD/gAAD//wAA/wAAB//8AAP8AAA///AAD/AAAf+fwAA/gAAP/n8AAP4AAH/x/AAD+AAD/4fwAA/gAB/8H8AAP8AAf+B/AAD/AAP/AfwAA/4AH/gH8AAH/AH/wB/AAB/8H/4AfwAAP///8AH8AAD////AB/AAAf///gAfwAAD///wAH8AAAf//4AB/AAAD//4AAfwAAAP/8AAH8AAAAf4AAB/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAADgAAAfwAAAB+AAAH8AAAAfwAAB/AAAAH+AAAfwAAAB/wAAH8AAAA/+AAB/AAAAP/gAAfwA4AA/8AAH8AfgAH/AAB/AP8AA/4AAfwD/gAH+AAH8B/4AB/gAB/A/8AAf4AAfwf/AAD+AAH8P/wAA/gAB/H/8AAf4AAfz//gAH+AAH8//4AB/gAB/f//AA/4AAf/+/4Af8AAH//P/AP/AAB//j////gAAf/wf///4AAH/4H///8AAB/8A///+AAAf+AH///AAAH/AA///gAAB/gAD//wAAAfwAAP/wAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAAAAAAH/wAAAAAAAH/8AAAAAAAH//AAAAAAAH//wAAAAAAH//8AAAAAAH///AAAAAAH///wAAAAAH///8AAAAAP//9/AAAAAP//8fwAAAAP//4H8AAAAP//4B/AAAAP//4AfwAAAP//4AH8AAAD//4AB/AAAA//4AAfwAAAP/4AAH8AAAD/wAAB/AAAA/wAAAfwAAAPwAH////AADwAB////wAAwAAf///8AAAAAH////AAAAAB////wAAAAAf///8AAAAAH////AAAAAA////wAAAAAAAfwAAAAAAAAH8AAAAAAAAB/AAAAAAAAAfwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAAAAAGAHwAAAB///gB+AAAH///8AfwAAB////AP+AAAf///wD/wAAH///+A/+AAB////gP/gAAf///4A/8AAH/8P8AH/AAB/AD+AA/4AAfwA/gAH+AAH8AfwAB/gAB/AH8AAf4AAfwB/AAH+AAH8AfwAB/gAB/AH8AAf4AAfwB/gAH+AAH8Af4AB/gAB/AH/AA/wAAfwB/4Af8AAH8AP/AP/AAB/AD////gAAfwAf///wAAH8AD///8AAB/AA///+AAAfwAH///AAAAAAA///gAAAAAAD//gAAAAAAAP/gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB///4AAAAAH////wAAAAH/////AAAAD/////4AAAB//////AAAA//////4AAAf//////AAAP//////4AAD/8D/w/+AAB/4B/wD/wAAf8A/wAf8AAP+AP4AD/gAD/AD+AAf4AA/wB/AAH+AAP4AfwAB/gAD+AH8AAf4AA/gB/AAH+AAP4AfwAB/gAD+AH+AAf4AA/wB/gAH+AAP8Af8AD/gAD/gH/gB/wAAf8A/8A/8AAH/AP///+AAB/gB////gAAPwAP///wAAB4AD///4AAAMAAf//8AAAAAAD//+AAAAAAAP/+AAAAAAAA/+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfwAAAAAAAAH8AAAAAAAAB/AAAAAAAAAfwAAAAAAAAH8AAAAAAAAB/AAAAABwAAfwAAAAB8AAH8AAAAD/AAB/AAAAD/wAAfwAAAH/8AAH8AAAH//AAB/AAAP//wAAfwAAP//8AAH8AAf//+AAB/AAf//8AAAfwA///8AAAH8A///4AAAB/A///4AAAAfx///wAAAAH9///wAAAAB////gAAAAAf///gAAAAAH///AAAAAAB///AAAAAAAf/+AAAAAAAH/+AAAAAAAB/8AAAAAAAAf8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAf/AAAAAP+Af/8AAAAP/4P//wAAAP//P//+AAAH//////wAAB//////8AAA///////gAAf//////8AAH////gP/AAD/wf/wA/wAA/4D/4AP+AAP8Af8AB/gAD/AH/AAf4AA/gA/wAH+AAP4AP4AA/gAD+AD/AAP4AA/gA/wAH+AAP8Af8AB/gAD/AH/AAf4AA/4D/4AP+AAP/B//AH/AAB////4D/wAAf//////8AAD//////+AAAf//////AAAH//////wAAA//8///4AAAD/+D//8AAAAP+Af/8AAAAAAAB/8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB/gAAAAAAAB//AAAAAAAB//8AAAAAAB///gAAgAAA///8AAcAAAf///gAPAAAH///8AH4AAD////AD/AAB/+H/4B/wAAf+Af+Af8AAP+AB/wD/gAD/gAf8Af4AA/wAD/AH+AAP8AA/wB/gAD+AAH8AP4AA/gAB/AD+AAP4AAfwB/gAD+AAH8Af4AA/wAD/AH+AAP8AA/gD/gAD/gAf4A/wAAf8AP8A/8AAH/gH/Af/AAA///////gAAP//////wAAB//////8AAAP/////+AAAB//////AAAAP/////AAAAA/////gAAAAD////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wA/wAAAAAP8AP8AAAAAD/AD/AAAAAA/wA/wAAAAAP8AP8AAAAAD/AD/AAAAAA/wA/wAAAAAP8AP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=='),
|
||||
46,
|
||||
atob("ExspGyUkJiQnISYnFQ=="),
|
||||
62+(scale<<8)+(1<<16)
|
||||
);
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
Graphics.prototype.setMediumFont = function(scale) {
|
||||
// Actual height 41 (42 - 2)
|
||||
this.setFontCustom(atob("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/AAAAAAAA/AAAAAAAA/AAAAAAAA/AAAAAAAA/AAAAAAAA/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAB/AAAAAAAP/AAAAAAD//AAAAAA///AAAAAP///AAAAB///8AAAAf///AAAAH///wAAAB///+AAAAH///gAAAAH//4AAAAAH/+AAAAAAH/wAAAAAAH8AAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA///8AAAAH////AAAAP////wAAAf////4AAA/////8AAB/////+AAD/gAAH+AAD+AAAD/AAH8AAAB/AAH4AAAA/gAH4AAAAfgAH4AAAAfgAPwAAAAfgAPwAAAAfgAPwAAAAfgAHwAAAAfgAH4AAAAfgAH4AAAA/gAH8AAAA/AAD+AAAD/AAD/gAAH/AAB/////+AAB/////8AAA/////4AAAf////wAAAH////gAAAB///+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPgAAAAAAAfwAAAAAAA/gAAAAAAA/AAAAAAAB/AAAAAAAD+AAAAAAAD8AAAAAAAH8AAAAAAAH//////AAH//////AAH//////AAH//////AAH//////AAH//////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4AAA/AAAP4AAB/AAAf4AAD/AAA/4AAD/AAB/4AAH/AAD/4AAP/AAH/AAAf/AAH8AAA//AAH4AAB//AAP4AAD//AAPwAAH+/AAPwAAP8/AAPwAAf4/AAPwAA/4/AAPwAA/w/AAPwAB/g/AAPwAD/A/AAP4AH+A/AAH8AP8A/AAH/A/4A/AAD///wA/AAD///gA/AAB///AA/AAA//+AA/AAAP/8AA/AAAD/wAA/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAH4AAAHwAAH4AAAH4AAH4AAAH8AAH4AAAP+AAH4AAAH+AAH4A4AB/AAH4A+AA/AAH4B/AA/gAH4D/AAfgAH4H+AAfgAH4P+AAfgAH4f+AAfgAH4/+AAfgAH5/+AAfgAH5//AAfgAH7+/AA/gAH/8/gB/AAH/4f4H/AAH/wf//+AAH/gP//8AAH/AH//8AAH+AD//wAAH8AB//gAAD4AAf+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+AAAAAAAD/AAAAAAAP/AAAAAAB//AAAAAAH//AAAAAAf//AAAAAB///AAAAAH///AAAAAf/8/AAAAB//w/AAAAH/+A/AAAA//4A/AAAD//gA/AAAH/+AA/AAAH/4AA/AAAH/gAA/AAAH+AAA/AAAHwAAA/AAAHAAf///AAEAAf///AAAAAf///AAAAAf///AAAAAf///AAAAAf///AAAAAAA/AAAAAAAA/AAAAAAAA/AAAAAAAA/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAP/AHgAAH///AP4AAH///gP8AAH///gP8AAH///gP+AAH///gD/AAH/A/AB/AAH4A/AA/gAH4A+AAfgAH4B+AAfgAH4B+AAfgAH4B8AAfgAH4B8AAfgAH4B+AAfgAH4B+AAfgAH4B+AA/gAH4B/AA/AAH4A/gD/AAH4A/4H+AAH4Af//+AAH4AP//8AAH4AP//4AAHwAD//wAAAAAB//AAAAAAAf8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA///8AAAAD////AAAAP////wAAAf////4AAA/////8AAB/////+AAD/gP4H+AAD/AfgD/AAH8A/AB/AAH8A/AA/gAH4B+AAfgAH4B+AAfgAPwB8AAfgAPwB8AAfgAPwB+AAfgAPwB+AAfgAH4B+AAfgAH4B/AA/gAH8B/AB/AAH+A/wD/AAD+A/8P+AAB8Af//+AAB4AP//8AAAwAH//4AAAAAD//gAAAAAA//AAAAAAAP4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPwAAAAAAAPwAAAAAAAPwAAAAAAAPwAAAAAAAPwAAAAHAAPwAAAA/AAPwAAAD/AAPwAAAf/AAPwAAB//AAPwAAP//AAPwAA//8AAPwAH//wAAPwAf/+AAAPwB//4AAAPwP//AAAAPw//8AAAAP3//gAAAAP//+AAAAAP//wAAAAAP//AAAAAAP/4AAAAAAP/gAAAAAAP+AAAAAAAHwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP+AAAAH+A//gAAAf/h//4AAA//z//8AAB/////+AAD/////+AAD///+H/AAH+H/4B/AAH8B/wA/gAH4A/gAfgAH4A/gAfgAPwA/AAfgAPwA/AAfgAPwA/AAfgAPwA/AAfgAH4A/gAfgAH4A/gAfgAH8B/wA/gAH/H/4B/AAD///+H/AAD/////+AAB/////+AAA//z//8AAAf/h//4AAAH+A//gAAAAAAH+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/gAAAAAAD/8AAAAAAP/+AAAAAAf//AAcAAA///gA8AAB///wB+AAD/x/4B/AAD+AP4B/AAH8AH8A/gAH4AH8A/gAH4AD8AfgAP4AD8AfgAPwAB8AfgAPwAB8AfgAPwAB8AfgAPwAB8AfgAH4AD8AfgAH4AD4A/gAH8AH4B/AAD+APwD/AAD/g/wP+AAB/////+AAA/////8AAAf////4AAAP////wAAAH////AAAAA///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD8APwAAAAD8APwAAAAD8APwAAAAD8APwAAAAD8APwAAAAD8APwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="), 46, atob("DxcjFyAfISAiHCAiEg=="), 54+(scale<<8)+(1<<16));
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
Graphics.prototype.setSmallFont = function(scale) {
|
||||
// Actual height 28 (27 - 0)
|
||||
this.setFontCustom(
|
||||
|
@ -71,6 +74,7 @@ Graphics.prototype.setSmallFont = function(scale) {
|
|||
return this;
|
||||
};
|
||||
|
||||
|
||||
function imgLock(){
|
||||
return {
|
||||
width : 16, height : 16, bpp : 1,
|
||||
|
@ -95,6 +99,14 @@ function imgBattery(){
|
|||
}
|
||||
}
|
||||
|
||||
function imgCharging() {
|
||||
return {
|
||||
width : 24, height : 24, bpp : 1,
|
||||
transparent : 1,
|
||||
buffer : require("heatshrink").decompress(atob("//+v///k///4AQPwBANgBoMxBoMb/P+h/w/kH8H4gfB+EBwfggHH4EAt4CBn4CBj4CBh4FCCIO/8EB//Agf/wEH/8Gh//x////fAQIA="))
|
||||
}
|
||||
}
|
||||
|
||||
function imgBpm() {
|
||||
return {
|
||||
width : 24, height : 24, bpp : 1,
|
||||
|
@ -111,6 +123,14 @@ function imgTemperature() {
|
|||
}
|
||||
}
|
||||
|
||||
function imgWeather(){
|
||||
return {
|
||||
width : 24, height : 24, bpp : 1,
|
||||
transparent : 0,
|
||||
buffer : require("heatshrink").decompress(atob("AAcYAQ0MgEwAQUAngLB/8AgP/wACCgf/4Fz//OAQQICCIoaCEAQpGHA4ACA="))
|
||||
}
|
||||
}
|
||||
|
||||
function imgWind () {
|
||||
return {
|
||||
width : 24, height : 24, bpp : 1,
|
||||
|
@ -127,14 +147,6 @@ function imgTimer() {
|
|||
}
|
||||
}
|
||||
|
||||
function imgCharging() {
|
||||
return {
|
||||
width : 24, height : 24, bpp : 1,
|
||||
transparent : 1,
|
||||
buffer : require("heatshrink").decompress(atob("//+v///k///4AQPwBANgBoMxBoMb/P+h/w/kH8H4gfB+EBwfggHH4EAt4CBn4CBj4CBh4FCCIO/8EB//Agf/wEH/8Gh//x////fAQIA="))
|
||||
}
|
||||
}
|
||||
|
||||
function imgWatch() {
|
||||
return {
|
||||
width : 24, height : 24, bpp : 1,
|
||||
|
@ -143,56 +155,102 @@ function imgWatch() {
|
|||
}
|
||||
}
|
||||
|
||||
function imgHomeAssistant() {
|
||||
return {
|
||||
width : 48, height : 48, bpp : 1,
|
||||
transparent : 0,
|
||||
buffer : require("heatshrink").decompress(atob("AD8BwAFDg/gAocP+AFDj4FEn/8Aod//wFD/1+FAf4j+8AoMD+EPDAUH+OPAoUP+fPAoUfBYk/C4l/EYIwC//8n//FwIFEgYFD4EH+E8nkP8BdBAonjjk44/wj/nzk58/4gAFDF4PgCIMHAoPwhkwh4FB/EEkEfIIWAHwIFC4A+BAoXgg4FDL4IFDL4IFDLIYFkAEQA=="))
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* INFO ENTRIES
|
||||
* List of [Data, Icon, left/right, Function to execute]
|
||||
|
||||
/************
|
||||
* 2D MENU with entries of:
|
||||
* [name, icon, opt[customUpFun], opt[customDownFun], opt[customCenterFun]]
|
||||
*
|
||||
* An example is shown below:
|
||||
*
|
||||
* Bpm ...
|
||||
* | |
|
||||
* Steps 10 min. ... ...
|
||||
* | | | |
|
||||
* Battery 5-min Temp. Trigger1
|
||||
* | | | |
|
||||
* BangleJs -- Timer -- Weather[Optional] -- HomeAssistant [Optional]
|
||||
*/
|
||||
var infoArray = [
|
||||
function(){ return [ null, null, "left", null ] },
|
||||
function(){ return [ "Bangle", imgWatch(), "right", null ] },
|
||||
function(){ return [ E.getBattery() + "%", imgBattery(), "left", null ] },
|
||||
function(){ return [ getSteps(), imgSteps(), "left", null ] },
|
||||
function(){ return [ Math.round(Bangle.getHealthStatus("last").bpm) + " bpm", imgBpm(), "left", null] },
|
||||
function(){ return [ getWeather().temp, imgTemperature(), "left", null ] },
|
||||
function(){ return [ getWeather().wind, imgWind(), "left", null ] },
|
||||
];
|
||||
var menu = [
|
||||
[
|
||||
function(){ return [ null, null ] },
|
||||
],
|
||||
[
|
||||
function(){ return [ "Bangle", imgWatch() ] },
|
||||
function(){ return [ E.getBattery() + "%", Bangle.isCharging() ? imgCharging() : imgBattery() ] },
|
||||
function(){ return [ getSteps(), imgSteps() ] },
|
||||
function(){ return [ Math.round(Bangle.getHealthStatus("last").bpm) + " bpm", imgBpm()] },
|
||||
]
|
||||
]
|
||||
|
||||
/*
|
||||
* We append the HomeAssistant integrations if HomeAssistant is available
|
||||
* Timer Menu
|
||||
*/
|
||||
try{
|
||||
require('sched');
|
||||
menu.push([
|
||||
function(){
|
||||
var text = isAlarmEnabled() ? getAlarmMinutes() + " min." : "Timer";
|
||||
return [text, imgTimer(), () => increaseAlarm(), () => decreaseAlarm(), null ]
|
||||
},
|
||||
]);
|
||||
} catch(ex) {
|
||||
// If sched is not installed, we hide this menu item
|
||||
}
|
||||
|
||||
/*
|
||||
* WEATHER MENU
|
||||
*/
|
||||
if(storage.readJSON('weather.json') !== undefined){
|
||||
menu.push([
|
||||
function(){ return [ "Weather", imgWeather() ] },
|
||||
function(){ return [ getWeather().temp, imgTemperature() ] },
|
||||
function(){ return [ getWeather().wind, imgWind() ] },
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HOME ASSISTANT MENU
|
||||
*/
|
||||
try{
|
||||
var triggers = require("ha.lib.js").getTriggers();
|
||||
var haMenu = [
|
||||
function(){ return [ "Home", imgHomeAssistant() ] },
|
||||
];
|
||||
|
||||
triggers.forEach(trigger => {
|
||||
infoArray.push(function(){
|
||||
return [trigger.display, trigger.getIcon(), "left", function(){
|
||||
haMenu.push(function(){
|
||||
return [trigger.display, trigger.getIcon(), () => {}, () => {}, function(){
|
||||
var ha = require("ha.lib.js");
|
||||
ha.sendTrigger("TRIGGER_BW");
|
||||
ha.sendTrigger(trigger.trigger);
|
||||
}]
|
||||
});
|
||||
})
|
||||
menu.push(haMenu);
|
||||
} catch(ex){
|
||||
// Nothing to do if HomeAssistant is not available...
|
||||
}
|
||||
const NUM_INFO=infoArray.length;
|
||||
|
||||
|
||||
function getInfoEntry(){
|
||||
if(isAlarmEnabled()){
|
||||
return [getAlarmMinutes() + " min.", imgTimer(), "left", null]
|
||||
} else if(Bangle.isCharging()){
|
||||
return [E.getBattery() + "%", imgCharging(), "left", null]
|
||||
} else{
|
||||
// In case the user removes HomeAssistant entries, showInfo
|
||||
// could be larger than infoArray.length...
|
||||
settings.showInfo = settings.showInfo % infoArray.length;
|
||||
return infoArray[settings.showInfo]();
|
||||
}
|
||||
// If HomeAssistant is not installed, we hide this item
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
function getMenuEntry(){
|
||||
// In case the user removes HomeAssistant entries, showInfo
|
||||
// could be larger than infoArray.length...
|
||||
settings.menuPosX = settings.menuPosX % menu.length;
|
||||
settings.menuPosY = settings.menuPosY % menu[settings.menuPosX].length;
|
||||
return menu[settings.menuPosX][settings.menuPosY]();
|
||||
}
|
||||
|
||||
|
||||
/************
|
||||
* Helper
|
||||
*/
|
||||
function getSteps() {
|
||||
|
@ -229,7 +287,7 @@ function getWeather(){
|
|||
|
||||
// Wind
|
||||
const wind = locale.speed(weather.wind).match(/^(\D*\d*)(.*)$/);
|
||||
weather.wind = Math.round(wind[1]) + " km/h";
|
||||
weather.wind = Math.round(wind[1]) + "kph";
|
||||
|
||||
return weather
|
||||
|
||||
|
@ -238,15 +296,16 @@ function getWeather(){
|
|||
}
|
||||
|
||||
return {
|
||||
temp: "? °C",
|
||||
hum: "-",
|
||||
txt: "-",
|
||||
wind: "? km/h",
|
||||
wdir: "-",
|
||||
wrose: "-"
|
||||
temp: " ? ",
|
||||
hum: " ? ",
|
||||
txt: " ? ",
|
||||
wind: " ? ",
|
||||
wdir: " ? ",
|
||||
wrose: " ? "
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function isAlarmEnabled(){
|
||||
try{
|
||||
var alarm = require('sched');
|
||||
|
@ -261,6 +320,7 @@ function isAlarmEnabled(){
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
function getAlarmMinutes(){
|
||||
if(!isAlarmEnabled()){
|
||||
return -1;
|
||||
|
@ -271,6 +331,7 @@ function getAlarmMinutes(){
|
|||
return Math.round(alarm.getTimeToAlarm(alarmObj)/(60*1000));
|
||||
}
|
||||
|
||||
|
||||
function increaseAlarm(){
|
||||
try{
|
||||
var minutes = isAlarmEnabled() ? getAlarmMinutes() : 0;
|
||||
|
@ -282,6 +343,7 @@ function increaseAlarm(){
|
|||
} catch(ex){ }
|
||||
}
|
||||
|
||||
|
||||
function decreaseAlarm(){
|
||||
try{
|
||||
var minutes = getAlarmMinutes();
|
||||
|
@ -301,10 +363,9 @@ function decreaseAlarm(){
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* DRAW functions
|
||||
/************
|
||||
* DRAW
|
||||
*/
|
||||
|
||||
function draw() {
|
||||
// Queue draw again
|
||||
queueDraw();
|
||||
|
@ -323,8 +384,8 @@ function drawDate(){
|
|||
g.reset().clearRect(0,0,W,W);
|
||||
|
||||
// Draw date
|
||||
y = parseInt(y/2);
|
||||
y += settings.fullscreen ? 2 : 15;
|
||||
y = parseInt(y/2)+4;
|
||||
y += settings.fullscreen ? 0 : 13;
|
||||
var date = new Date();
|
||||
var dateStr = date.getDate();
|
||||
dateStr = ("0" + dateStr).substr(-2);
|
||||
|
@ -338,13 +399,12 @@ function drawDate(){
|
|||
var fullDateW = dateW + 10 + dayW;
|
||||
|
||||
g.setFontAlign(-1,0);
|
||||
g.drawString(dayStr, W/2 - fullDateW/2 + 10 + dateW, y-12);
|
||||
g.drawString(monthStr, W/2 - fullDateW/2 + 10 + dateW, y+11);
|
||||
|
||||
g.setMediumFont();
|
||||
g.setColor(g.theme.fg);
|
||||
g.drawString(dateStr, W/2 - fullDateW / 2, y+1);
|
||||
|
||||
g.setSmallFont();
|
||||
g.drawString(dayStr, W/2 - fullDateW/2 + 10 + dateW, y-12);
|
||||
g.drawString(monthStr, W/2 - fullDateW/2 + 10 + dateW, y+11);
|
||||
}
|
||||
|
||||
|
||||
|
@ -368,13 +428,13 @@ function drawTime(){
|
|||
// Set y coordinates correctly
|
||||
y += parseInt((H - y)/2) + 5;
|
||||
|
||||
var infoEntry = getInfoEntry();
|
||||
var infoStr = infoEntry[0];
|
||||
var infoImg = infoEntry[1];
|
||||
var printImgLeft = infoEntry[2] == "left";
|
||||
var menuEntry = getMenuEntry();
|
||||
var menuName = menuEntry[0];
|
||||
var menuImg = menuEntry[1];
|
||||
var printImgLeft = settings.menuPosY != 0;
|
||||
|
||||
// Show large or small time depending on info entry
|
||||
if(infoStr == null){
|
||||
if(menuName == null){
|
||||
if(settings.hideColon){
|
||||
g.setXLargeFont();
|
||||
} else {
|
||||
|
@ -386,8 +446,8 @@ function drawTime(){
|
|||
}
|
||||
g.drawString(timeStr, W/2, y);
|
||||
|
||||
// Draw info if set
|
||||
if(infoStr == null){
|
||||
// Draw menu if set
|
||||
if(menuName == null){
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -395,18 +455,18 @@ function drawTime(){
|
|||
g.setFontAlign(0,0);
|
||||
g.setSmallFont();
|
||||
var imgWidth = 0;
|
||||
if(infoImg !== undefined){
|
||||
imgWidth = 26.0;
|
||||
var strWidth = g.stringWidth(infoStr);
|
||||
var scale = imgWidth / infoImg.width;
|
||||
if(menuImg !== undefined){
|
||||
imgWidth = 24.0;
|
||||
var strWidth = g.stringWidth(menuName);
|
||||
var scale = imgWidth / menuImg.width;
|
||||
g.drawImage(
|
||||
infoImg,
|
||||
menuImg,
|
||||
W/2 + (printImgLeft ? -strWidth/2-2 : strWidth/2+2) - parseInt(imgWidth/2),
|
||||
y - parseInt(imgWidth/2),
|
||||
{ scale: scale }
|
||||
);
|
||||
}
|
||||
g.drawString(infoStr, printImgLeft ? W/2 + imgWidth/2 + 2 : W/2 - imgWidth/2 - 2, y+3);
|
||||
g.drawString(menuName, printImgLeft ? W/2 + imgWidth/2 + 2 : W/2 - imgWidth/2 - 2, y+3);
|
||||
}
|
||||
|
||||
|
||||
|
@ -463,6 +523,10 @@ Bangle.on('lock', function(isLocked) {
|
|||
Bangle.on('charging',function(charging) {
|
||||
if (drawTimeout) clearTimeout(drawTimeout);
|
||||
drawTimeout = undefined;
|
||||
|
||||
// Jump to battery
|
||||
settings.menuPosX = 1;
|
||||
settings.menuPosY = 1;
|
||||
draw();
|
||||
});
|
||||
|
||||
|
@ -480,36 +544,52 @@ Bangle.on('touch', function(btn, e){
|
|||
|
||||
if(is_upper){
|
||||
Bangle.buzz(40, 0.6);
|
||||
increaseAlarm();
|
||||
settings.menuPosY = (settings.menuPosY+1) % menu[settings.menuPosX].length;
|
||||
|
||||
// Handle custom menu entry function
|
||||
var menuEntry = getMenuEntry();
|
||||
if(menuEntry.length > 2){
|
||||
menuEntry[2]();
|
||||
}
|
||||
|
||||
drawTime();
|
||||
}
|
||||
|
||||
if(is_lower){
|
||||
Bangle.buzz(40, 0.6);
|
||||
decreaseAlarm();
|
||||
settings.menuPosY = settings.menuPosY-1;
|
||||
settings.menuPosY = settings.menuPosY < 0 ? menu[settings.menuPosX].length-1 : settings.menuPosY;
|
||||
|
||||
// Handle custom menu entry function
|
||||
var menuEntry = getMenuEntry();
|
||||
if(menuEntry.length > 3){
|
||||
menuEntry[3]();
|
||||
}
|
||||
|
||||
drawTime();
|
||||
}
|
||||
|
||||
if(is_right){
|
||||
Bangle.buzz(40, 0.6);
|
||||
settings.showInfo = (settings.showInfo+1) % NUM_INFO;
|
||||
settings.menuPosX = (settings.menuPosX+1) % menu.length;
|
||||
settings.menuPosY = 0;
|
||||
drawTime();
|
||||
}
|
||||
|
||||
if(is_left){
|
||||
Bangle.buzz(40, 0.6);
|
||||
settings.showInfo = settings.showInfo-1;
|
||||
settings.showInfo = settings.showInfo < 0 ? NUM_INFO-1 : settings.showInfo;
|
||||
settings.menuPosY = 0;
|
||||
settings.menuPosX = settings.menuPosX-1;
|
||||
settings.menuPosX = settings.menuPosX < 0 ? menu.length-1 : settings.menuPosX;
|
||||
drawTime();
|
||||
}
|
||||
|
||||
if(is_center){
|
||||
var infoEntry = getInfoEntry();
|
||||
var fun = infoEntry[3];
|
||||
if(fun != null){
|
||||
var menuEntry = getMenuEntry();
|
||||
if(menuEntry.length > 4){
|
||||
Bangle.buzz(80, 0.6).then(()=>{
|
||||
try{
|
||||
fun();
|
||||
menuEntry[4]();
|
||||
setTimeout(()=>{
|
||||
Bangle.buzz(80, 0.6);
|
||||
}, 250);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"id": "bwclk",
|
||||
"name": "BW Clock",
|
||||
"version": "0.11",
|
||||
"description": "BW Clock.",
|
||||
"version": "0.12",
|
||||
"description": "A very minimalistic clock with date and time in focus.",
|
||||
"readme": "README.md",
|
||||
"icon": "app.png",
|
||||
"screenshots": [{"url":"screenshot.png"}, {"url":"screenshot_2.png"}, {"url":"screenshot_3.png"}, {"url":"screenshot_4.png"}],
|
||||
|
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.2 KiB |
|
@ -53,3 +53,4 @@
|
|||
0.38: Add telegram foss handling
|
||||
0.39: Set default color for message icons according to theme
|
||||
0.40: Use default Bangle formatter for booleans
|
||||
0.41: Add notification icons in the widget
|
|
@ -22,12 +22,13 @@ it starts getting clipped.
|
|||
* `Auto-Open Music` - Should the app automatically open when the phone starts playing music?
|
||||
* `Unlock Watch` - Should the app unlock the watch when a new message arrives, so you can touch the buttons at the bottom of the app?
|
||||
* `Flash Icon` - Toggle flashing of the widget icon.
|
||||
* `Widget messages` - The maximum amount of message icons to show on the widget.
|
||||
|
||||
## New Messages
|
||||
|
||||
When a new message is received:
|
||||
|
||||
* If you're in an app, the Bangle will buzz and a 'new message' icon appears in the Widget bar. You can tap this bar to view the message.
|
||||
* If you're in an app, the Bangle will buzz and a message icon appears in the Widget bar. You can tap this icon to view the message.
|
||||
* If you're in a clock, the Messages app will automatically start and show the message
|
||||
|
||||
When a message is shown, you'll see a screen showing the message title and text.
|
||||
|
|
|
@ -85,7 +85,7 @@ exports.pushMessage = function(event) {
|
|||
return load("messages.app.js");
|
||||
}
|
||||
if (!quiet && (!global.WIDGETS || !WIDGETS.messages)) return Bangle.buzz(); // no widgets - just buzz to let someone know
|
||||
WIDGETS.messages.show();
|
||||
if (global.WIDGETS && WIDGETS.messages) WIDGETS.messages.update(messages);
|
||||
}, 500);
|
||||
}
|
||||
/// Remove all messages
|
||||
|
@ -102,7 +102,7 @@ exports.clearAll = function(event) {
|
|||
if (inApp) return onMessagesModified();
|
||||
// if we have a widget, update it
|
||||
if (global.WIDGETS && WIDGETS.messages)
|
||||
WIDGETS.messages.hide();
|
||||
WIDGETS.messages.update(messages);
|
||||
}
|
||||
|
||||
exports.getMessageImage = function(msg) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "messages",
|
||||
"name": "Messages",
|
||||
"version": "0.40",
|
||||
"version": "0.41",
|
||||
"description": "App to display notifications from iOS and Gadgetbridge/Android",
|
||||
"icon": "app.png",
|
||||
"type": "app",
|
||||
|
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.9 KiB |
|
@ -4,6 +4,7 @@
|
|||
if (settings.vibrate===undefined) settings.vibrate=":";
|
||||
if (settings.repeat===undefined) settings.repeat=4;
|
||||
if (settings.unreadTimeout===undefined) settings.unreadTimeout=60;
|
||||
if (settings.maxMessages===undefined) settings.maxMessages=3;
|
||||
settings.unlockWatch=!!settings.unlockWatch;
|
||||
settings.openMusic=!!settings.openMusic;
|
||||
settings.maxUnreadTimeout=240;
|
||||
|
@ -54,6 +55,11 @@
|
|||
value: !!settings().quietNoAutOpn,
|
||||
onchange: v => updateSetting("quietNoAutOpn", v)
|
||||
},
|
||||
/*LANG*/'Widget messages': {
|
||||
value:0|settings().maxMessages,
|
||||
min: 1, max: 5,
|
||||
onchange: v => updateSetting("maxMessages", v)
|
||||
}
|
||||
};
|
||||
E.showMenu(mainmenu);
|
||||
})
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
(() => {
|
||||
|
||||
function getMessages() {
|
||||
if ("undefined"!=typeof MESSAGES) return MESSAGES;
|
||||
return require("Storage").readJSON("messages.json",1)||[];
|
||||
}
|
||||
|
||||
function filterMessages(msgs) {
|
||||
return msgs.filter(msg => msg.new && msg.id != "music")
|
||||
.filter((msg, i, arr) => arr.findIndex(nmsg => msg.src == nmsg.src) == i);
|
||||
}
|
||||
|
||||
WIDGETS["messages"]={area:"tl", width:0, iconwidth:24,
|
||||
draw:function(recall) {
|
||||
// If we had a setTimeout queued from the last time we were called, remove it
|
||||
|
@ -11,8 +23,21 @@ draw:function(recall) {
|
|||
let settings = require('Storage').readJSON("messages.settings.json", true) || {};
|
||||
if (settings.flash===undefined) settings.flash = true;
|
||||
if (recall !== true || settings.flash) {
|
||||
var msgsShown = E.clip(this.msgs.length, 0, settings.maxMessages);
|
||||
g.reset().clearRect(this.x, this.y, this.x+this.width, this.y+23);
|
||||
g.drawImage(settings.flash && (c&1) ? atob("GBiBAAAAAAAAAAAAAAAAAAAAAB//+DAADDAADDAADDwAPD8A/DOBzDDn/DA//DAHvDAPvjAPvjAPvjAPvh///gf/vAAD+AAB8AAAAA==") : atob("GBiBAAAAAAAAAAAAAAAAAAAAAB//+D///D///A//8CP/xDj/HD48DD+B8D/D+D/3vD/vvj/vvj/vvj/vvh/v/gfnvAAD+AAB8AAAAA=="), this.x, this.y-1);
|
||||
for(let i = 0;i < msgsShown;i++) {
|
||||
const msg = this.msgs[i];
|
||||
const colors = [g.theme.bg, g.setColor(require("messages").getMessageImageCol(msg)).getColor()];
|
||||
if (settings.flash && (c&1)) {
|
||||
if (colors[1] == g.theme.fg) {
|
||||
colors.reverse();
|
||||
} else {
|
||||
colors[1] = g.theme.fg;
|
||||
}
|
||||
}
|
||||
g.setColor(colors[1]).setBgColor(colors[0]);
|
||||
g.drawImage(i == (settings.maxMessages - 1) && msgs.length > settings.maxMessages ? atob("GBgBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH4H4H4H4H4H4H4H4H4H4H4H4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") : require("messages").getMessageImage(msg), this.x + i * this.iconwidth, this.y - 1);
|
||||
}
|
||||
}
|
||||
if (settings.repeat===undefined) settings.repeat = 4;
|
||||
if (c<120 && (Date.now()-this.l)>settings.repeat*1000) {
|
||||
|
@ -21,16 +46,19 @@ draw:function(recall) {
|
|||
}
|
||||
WIDGETS["messages"].i=setTimeout(()=>WIDGETS["messages"].draw(true), 1000);
|
||||
if (process.env.HWVERSION>1) Bangle.on('touch', this.touch);
|
||||
},show:function(quiet) {
|
||||
WIDGETS["messages"].t=Date.now(); // first time
|
||||
WIDGETS["messages"].l=Date.now()-10000; // last buzz
|
||||
if (quiet) WIDGETS["messages"].t -= 500000; // if quiet, set last time in the past so there is no buzzing
|
||||
WIDGETS["messages"].width=this.iconwidth;
|
||||
Bangle.drawWidgets();
|
||||
},hide:function() {
|
||||
delete WIDGETS["messages"].t;
|
||||
delete WIDGETS["messages"].l;
|
||||
WIDGETS["messages"].width=0;
|
||||
},update:function(rawMsgs, quiet) {
|
||||
const settings = require('Storage').readJSON("messages.settings.json", true) || {};
|
||||
msgs = filterMessages(rawMsgs);
|
||||
if (msgs.length === 0) {
|
||||
delete WIDGETS["messages"].t;
|
||||
delete WIDGETS["messages"].l;
|
||||
} else {
|
||||
WIDGETS["messages"].t=Date.now(); // first time
|
||||
WIDGETS["messages"].l=Date.now()-10000; // last buzz
|
||||
if (quiet) WIDGETS["messages"].t -= 500000; // if quiet, set last time in the past so there is no buzzing
|
||||
}
|
||||
WIDGETS["messages"].width=this.iconwidth * E.clip(msgs.length, 0, settings.maxMessages);
|
||||
WIDGETS["messages"].msgs = msgs;
|
||||
Bangle.drawWidgets();
|
||||
},buzz:function() {
|
||||
if ((require('Storage').readJSON('setting.json',1)||{}).quiet) return; // never buzz during Quiet Mode
|
||||
|
@ -40,10 +68,11 @@ draw:function(recall) {
|
|||
if (!w||!w.width||c.x<w.x||c.x>w.x+w.width||c.y<w.y||c.y>w.y+w.iconwidth) return;
|
||||
load("messages.app.js");
|
||||
}};
|
||||
|
||||
/* We might have returned here if we were in the Messages app for a
|
||||
message but then the watch was never viewed. In that case we don't
|
||||
want to buzz but should still show that there are unread messages. */
|
||||
if (global.MESSAGES===undefined) (function() {
|
||||
var messages = require("Storage").readJSON("messages.json",1)||[];
|
||||
if (messages.some(m=>m.new&&m.id!="music")) WIDGETS["messages"].show(true);
|
||||
if (global.MESSAGES===undefined)
|
||||
WIDGETS["messages"].update(getMessages(), true);
|
||||
|
||||
})();
|
||||
|
|
|
@ -6,3 +6,4 @@
|
|||
0.05: Fix warning calculation
|
||||
Show difference of last measurement to pressure average of the the last three hours in the widget
|
||||
Only use valid pressure values
|
||||
0.06: Fix exception
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"id": "widbaroalarm",
|
||||
"name": "Barometer Alarm Widget",
|
||||
"shortName": "Barometer Alarm",
|
||||
"version": "0.05",
|
||||
"version": "0.06",
|
||||
"description": "A widget that can alarm on when the pressure reaches defined thresholds.",
|
||||
"icon": "widget.png",
|
||||
"type": "widget",
|
||||
|
|
|
@ -231,15 +231,15 @@ function getPressureValue() {
|
|||
if (isValidPressureValue(pressure)) {
|
||||
currentPressures.unshift(pressure);
|
||||
median = currentPressures.slice().sort();
|
||||
}
|
||||
|
||||
if (median.length > 10) {
|
||||
var mid = median.length >> 1;
|
||||
medianPressure = Math.round(E.sum(median.slice(mid - 4, mid + 5)) / 9);
|
||||
if (medianPressure > 0) {
|
||||
turnOff();
|
||||
draw();
|
||||
handlePressureValue(medianPressure);
|
||||
if (median.length > 10) {
|
||||
var mid = median.length >> 1;
|
||||
medianPressure = Math.round(E.sum(median.slice(mid - 4, mid + 5)) / 9);
|
||||
if (medianPressure > 0) {
|
||||
turnOff();
|
||||
draw();
|
||||
handlePressureValue(medianPressure);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{ "id": "widscrlock",
|
||||
"name": "Screenlock Widget",
|
||||
"shortName":"Screenlock",
|
||||
"version":"0.02",
|
||||
"version":"0.03",
|
||||
"description": "Lock a Bangle 2 screen by tapping a widget.",
|
||||
"icon": "widget.png",
|
||||
"type": "widget",
|
||||
|
|
|
@ -23,13 +23,13 @@ if (DEVICE=="BANGLEJS") {
|
|||
var OUTFILE = path.join(ROOTDIR, '../Espruino/libs/banglejs/banglejs1_storage_default.c');
|
||||
var APPS = [ // IDs of apps to install
|
||||
"boot","launch","mclock","setting",
|
||||
"about","alarm","widbat","widbt","welcome"
|
||||
"about","alarm","sched","widbat","widbt","welcome"
|
||||
];
|
||||
} else if (DEVICE=="BANGLEJS2") {
|
||||
var OUTFILE = path.join(ROOTDIR, '../Espruino/libs/banglejs/banglejs2_storage_default.c');
|
||||
var APPS = [ // IDs of apps to install
|
||||
"boot","launch","antonclk","setting",
|
||||
"about","alarm","health","widlock","widbat","widbt","widid","welcome"
|
||||
"about","alarm","sched","health","widlock","widbat","widbt","widid","welcome"
|
||||
];
|
||||
} else {
|
||||
console.log("USAGE:");
|
||||
|
|
|
@ -17,13 +17,21 @@ try {
|
|||
}
|
||||
|
||||
var BASEDIR = __dirname+"/../";
|
||||
var APPSDIR = BASEDIR+"apps/";
|
||||
function ERROR(s) {
|
||||
console.error("ERROR: "+s);
|
||||
process.exit(1);
|
||||
var APPSDIR_RELATIVE = "apps/";
|
||||
var APPSDIR = BASEDIR + APPSDIR_RELATIVE;
|
||||
var warningCount = 0;
|
||||
var errorCount = 0;
|
||||
function ERROR(msg, opt) {
|
||||
// file=app.js,line=1,col=5,endColumn=7
|
||||
opt = opt||{};
|
||||
console.log(`::error${Object.keys(opt).length?" ":""}${Object.keys(opt).map(k=>k+"="+opt[k]).join(",")}::${msg}`);
|
||||
errorCount++;
|
||||
}
|
||||
function WARN(s) {
|
||||
console.log("Warning: "+s);
|
||||
function WARN(msg, opt) {
|
||||
// file=app.js,line=1,col=5,endColumn=7
|
||||
opt = opt||{};
|
||||
console.log(`::warning${Object.keys(opt).length?" ":""}${Object.keys(opt).map(k=>k+"="+opt[k]).join(",")}::${msg}`);
|
||||
warningCount++;
|
||||
}
|
||||
|
||||
var apps = [];
|
||||
|
@ -43,16 +51,20 @@ dirs.forEach(dir => {
|
|||
} catch (e) {
|
||||
console.log(e);
|
||||
var m = e.toString().match(/in JSON at position (\d+)/);
|
||||
var messageInfo = {
|
||||
file : "apps/"+dir.name+"/metadata.json",
|
||||
};
|
||||
if (m) {
|
||||
var char = parseInt(m[1]);
|
||||
messageInfo.line = appsFile.substr(0,char).split("\n").length;
|
||||
console.log("===============================================");
|
||||
console.log("LINE "+appsFile.substr(0,char).split("\n").length);
|
||||
console.log("LINE "+messageInfo.line);
|
||||
console.log("===============================================");
|
||||
console.log(appsFile.substr(char-10, 20));
|
||||
console.log("===============================================");
|
||||
}
|
||||
console.log(m);
|
||||
ERROR(dir.name+"/metadata.json not valid JSON");
|
||||
ERROR(messageInfo.file+" not valid JSON", messageInfo);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -87,87 +99,90 @@ let allFiles = [];
|
|||
let existingApps = [];
|
||||
apps.forEach((app,appIdx) => {
|
||||
if (!app.id) ERROR(`App ${appIdx} has no id`);
|
||||
if (existingApps.includes(app.id)) ERROR(`Duplicate app '${app.id}'`);
|
||||
var appDirRelative = APPSDIR_RELATIVE+app.id+"/";
|
||||
var appDir = APPSDIR+app.id+"/";
|
||||
var metadataFile = appDirRelative+"metadata.json";
|
||||
if (existingApps.includes(app.id)) ERROR(`Duplicate app '${app.id}'`, {file:metadataFile});
|
||||
existingApps.push(app.id);
|
||||
//console.log(`Checking ${app.id}...`);
|
||||
var appDir = APPSDIR+app.id+"/";
|
||||
|
||||
if (!fs.existsSync(APPSDIR+app.id)) ERROR(`App ${app.id} has no directory`);
|
||||
if (!app.name) ERROR(`App ${app.id} has no name`);
|
||||
if (!app.name) ERROR(`App ${app.id} has no name`, {file:metadataFile});
|
||||
var isApp = !app.type || app.type=="app";
|
||||
if (app.name.length>20 && !app.shortName && isApp) ERROR(`App ${app.id} has a long name, but no shortName`);
|
||||
if (app.name.length>20 && !app.shortName && isApp) ERROR(`App ${app.id} has a long name, but no shortName`, {file:metadataFile});
|
||||
if (app.type && !METADATA_TYPES.includes(app.type))
|
||||
ERROR(`App ${app.id} 'type' is one one of `+METADATA_TYPES);
|
||||
if (!Array.isArray(app.supports)) ERROR(`App ${app.id} has no 'supports' field or it's not an array`);
|
||||
ERROR(`App ${app.id} 'type' is one one of `+METADATA_TYPES, {file:metadataFile});
|
||||
if (!Array.isArray(app.supports)) ERROR(`App ${app.id} has no 'supports' field or it's not an array`, {file:metadataFile});
|
||||
else {
|
||||
app.supports.forEach(dev => {
|
||||
if (!SUPPORTS_DEVICES.includes(dev))
|
||||
ERROR(`App ${app.id} has unknown device in 'supports' field - ${dev}`);
|
||||
ERROR(`App ${app.id} has unknown device in 'supports' field - ${dev}`, {file:metadataFile});
|
||||
});
|
||||
}
|
||||
|
||||
if (!app.version) WARN(`App ${app.id} has no version`);
|
||||
if (!app.version) ERROR(`App ${app.id} has no version`, {file:metadataFile});
|
||||
else {
|
||||
if (!fs.existsSync(appDir+"ChangeLog")) {
|
||||
if (app.version != "0.01")
|
||||
WARN(`App ${app.id} has no ChangeLog`);
|
||||
WARN(`App ${app.id} has no ChangeLog`, {file:metadataFile});
|
||||
} else {
|
||||
var changeLog = fs.readFileSync(appDir+"ChangeLog").toString();
|
||||
var versions = changeLog.match(/\d+\.\d+:/g);
|
||||
if (!versions) ERROR(`No versions found in ${app.id} ChangeLog (${appDir}ChangeLog)`);
|
||||
if (!versions) ERROR(`No versions found in ${app.id} ChangeLog (${appDir}ChangeLog)`, {file:metadataFile});
|
||||
var lastChangeLog = versions.pop().slice(0,-1);
|
||||
if (lastChangeLog != app.version)
|
||||
WARN(`App ${app.id} app version (${app.version}) and ChangeLog (${lastChangeLog}) don't agree`);
|
||||
ERROR(`App ${app.id} app version (${app.version}) and ChangeLog (${lastChangeLog}) don't agree`, {file:appDirRelative+"ChangeLog", line:changeLog.split("\n").length-1});
|
||||
}
|
||||
}
|
||||
if (!app.description) ERROR(`App ${app.id} has no description`);
|
||||
if (!app.icon) ERROR(`App ${app.id} has no icon`);
|
||||
if (!fs.existsSync(appDir+app.icon)) ERROR(`App ${app.id} icon doesn't exist`);
|
||||
if (!app.description) ERROR(`App ${app.id} has no description`, {file:metadataFile});
|
||||
if (!app.icon) ERROR(`App ${app.id} has no icon`, {file:metadataFile});
|
||||
if (!fs.existsSync(appDir+app.icon)) ERROR(`App ${app.id} icon doesn't exist`, {file:metadataFile});
|
||||
if (app.screenshots) {
|
||||
if (!Array.isArray(app.screenshots)) ERROR(`App ${app.id} screenshots is not an array`);
|
||||
if (!Array.isArray(app.screenshots)) ERROR(`App ${app.id} screenshots is not an array`, {file:metadataFile});
|
||||
app.screenshots.forEach(screenshot => {
|
||||
if (!fs.existsSync(appDir+screenshot.url))
|
||||
ERROR(`App ${app.id} screenshot file ${screenshot.url} not found`);
|
||||
ERROR(`App ${app.id} screenshot file ${screenshot.url} not found`, {file:metadataFile});
|
||||
});
|
||||
}
|
||||
if (app.readme && !fs.existsSync(appDir+app.readme)) ERROR(`App ${app.id} README file doesn't exist`);
|
||||
if (app.custom && !fs.existsSync(appDir+app.custom)) ERROR(`App ${app.id} custom HTML doesn't exist`);
|
||||
if (app.customConnect && !app.custom) ERROR(`App ${app.id} has customConnect but no customn HTML`);
|
||||
if (app.interface && !fs.existsSync(appDir+app.interface)) ERROR(`App ${app.id} interface HTML doesn't exist`);
|
||||
if (app.readme && !fs.existsSync(appDir+app.readme)) ERROR(`App ${app.id} README file doesn't exist`, {file:metadataFile});
|
||||
if (app.custom && !fs.existsSync(appDir+app.custom)) ERROR(`App ${app.id} custom HTML doesn't exist`, {file:metadataFile});
|
||||
if (app.customConnect && !app.custom) ERROR(`App ${app.id} has customConnect but no customn HTML`, {file:metadataFile});
|
||||
if (app.interface && !fs.existsSync(appDir+app.interface)) ERROR(`App ${app.id} interface HTML doesn't exist`, {file:metadataFile});
|
||||
if (app.dependencies) {
|
||||
if (("object"==typeof app.dependencies) && !Array.isArray(app.dependencies)) {
|
||||
Object.keys(app.dependencies).forEach(dependency => {
|
||||
if (!["type","app"].includes(app.dependencies[dependency]))
|
||||
ERROR(`App ${app.id} 'dependencies' must all be tagged 'type' or 'app' right now`);
|
||||
ERROR(`App ${app.id} 'dependencies' must all be tagged 'type' or 'app' right now`, {file:metadataFile});
|
||||
if (app.dependencies[dependency]=="type" && !METADATA_TYPES.includes(dependency))
|
||||
ERROR(`App ${app.id} 'type' dependency must be one of `+METADATA_TYPES);
|
||||
ERROR(`App ${app.id} 'type' dependency must be one of `+METADATA_TYPES, {file:metadataFile});
|
||||
|
||||
});
|
||||
} else
|
||||
ERROR(`App ${app.id} 'dependencies' must be an object`);
|
||||
ERROR(`App ${app.id} 'dependencies' must be an object`, {file:metadataFile});
|
||||
}
|
||||
var fileNames = [];
|
||||
app.storage.forEach((file) => {
|
||||
if (!file.name) ERROR(`App ${app.id} has a file with no name`);
|
||||
if (isGlob(file.name)) ERROR(`App ${app.id} storage file ${file.name} contains wildcards`);
|
||||
if (!file.name) ERROR(`App ${app.id} has a file with no name`, {file:metadataFile});
|
||||
if (isGlob(file.name)) ERROR(`App ${app.id} storage file ${file.name} contains wildcards`, {file:metadataFile});
|
||||
let char = file.name.match(FORBIDDEN_FILE_NAME_CHARS)
|
||||
if (char) ERROR(`App ${app.id} storage file ${file.name} contains invalid character "${char[0]}"`)
|
||||
if (char) ERROR(`App ${app.id} storage file ${file.name} contains invalid character "${char[0]}"`, {file:metadataFile})
|
||||
if (fileNames.includes(file.name) && !file.supports) // assume that there aren't duplicates if 'supports' is set
|
||||
ERROR(`App ${app.id} file ${file.name} is a duplicate`);
|
||||
ERROR(`App ${app.id} file ${file.name} is a duplicate`, {file:metadataFile});
|
||||
if (file.supports && !Array.isArray(file.supports))
|
||||
ERROR(`App ${app.id} file ${file.name} supports field must be an array`);
|
||||
ERROR(`App ${app.id} file ${file.name} supports field must be an array`, {file:metadataFile});
|
||||
if (file.supports)
|
||||
file.supports.forEach(dev => {
|
||||
if (!SUPPORTS_DEVICES.includes(dev))
|
||||
ERROR(`App ${app.id} file ${file.name} has unknown device in 'supports' field - ${dev}`);
|
||||
ERROR(`App ${app.id} file ${file.name} has unknown device in 'supports' field - ${dev}`, {file:metadataFile});
|
||||
});
|
||||
fileNames.push(file.name);
|
||||
allFiles.push({app: app.id, file: file.name});
|
||||
if (file.url) if (!fs.existsSync(appDir+file.url)) ERROR(`App ${app.id} file ${file.url} doesn't exist`);
|
||||
if (!file.url && !file.content && !app.custom) ERROR(`App ${app.id} file ${file.name} has no contents`);
|
||||
if (file.url) if (!fs.existsSync(appDir+file.url)) ERROR(`App ${app.id} file ${file.url} doesn't exist`, {file:metadataFile});
|
||||
if (!file.url && !file.content && !app.custom) ERROR(`App ${app.id} file ${file.name} has no contents`, {file:metadataFile});
|
||||
var fileContents = "";
|
||||
if (file.content) fileContents = file.content;
|
||||
if (file.url) fileContents = fs.readFileSync(appDir+file.url).toString();
|
||||
if (file.supports && !Array.isArray(file.supports)) ERROR(`App ${app.id} file ${file.name} supports field is not an array`);
|
||||
if (file.supports && !Array.isArray(file.supports)) ERROR(`App ${app.id} file ${file.name} supports field is not an array`, {file:metadataFile});
|
||||
if (file.evaluate) {
|
||||
try {
|
||||
acorn.parse("("+fileContents+")");
|
||||
|
@ -179,7 +194,7 @@ apps.forEach((app,appIdx) => {
|
|||
console.log("=====================================================");
|
||||
console.log(fileContents);
|
||||
console.log("=====================================================");
|
||||
ERROR(`App ${app.id}'s ${file.name} has evaluate:true but is not valid JS expression`);
|
||||
ERROR(`App ${app.id}'s ${file.name} has evaluate:true but is not valid JS expression`, {file:appDirRelative+file.url});
|
||||
}
|
||||
}
|
||||
if (file.name.endsWith(".js")) {
|
||||
|
@ -194,11 +209,11 @@ apps.forEach((app,appIdx) => {
|
|||
console.log("=====================================================");
|
||||
console.log(fileContents);
|
||||
console.log("=====================================================");
|
||||
ERROR(`App ${app.id}'s ${file.name} is a JS file but isn't valid JS`);
|
||||
ERROR(`App ${app.id}'s ${file.name} is a JS file but isn't valid JS`, {file:appDirRelative+file.url});
|
||||
}
|
||||
}
|
||||
for (const key in file) {
|
||||
if (!STORAGE_KEYS.includes(key)) ERROR(`App ${app.id} file ${file.name} has unknown key ${key}`);
|
||||
if (!STORAGE_KEYS.includes(key)) ERROR(`App ${app.id} file ${file.name} has unknown key ${key}`, {file:appDirRelative+file.url});
|
||||
}
|
||||
// warn if JS icon is the wrong size
|
||||
if (file.name == app.id+".img") {
|
||||
|
@ -209,44 +224,44 @@ apps.forEach((app,appIdx) => {
|
|||
else {
|
||||
match = fileContents.match(/^\s*require\(\"heatshrink\"\)\.decompress\(\s*atob\(\s*\"([^"]*)\"\s*\)\s*\)\s*$/);
|
||||
if (match) icon = heatshrink.decompress(Buffer.from(match[1], 'base64'));
|
||||
else ERROR(`JS icon ${file.name} does not match the pattern 'require("heatshrink").decompress(atob("..."))'`);
|
||||
else ERROR(`JS icon ${file.name} does not match the pattern 'require("heatshrink").decompress(atob("..."))'`, {file:appDirRelative+file.url});
|
||||
}
|
||||
if (match) {
|
||||
if (icon[0] > 48 || icon[0] < 24 || icon[1] > 48 || icon[1] < 24) {
|
||||
if (GRANDFATHERED_ICONS.includes(app.id)) WARN(`JS icon ${file.name} should be 48x48px (or slightly under) but is instead ${icon[0]}x${icon[1]}px`);
|
||||
else ERROR(`JS icon ${file.name} should be 48x48px (or slightly under) but is instead ${icon[0]}x${icon[1]}px`);
|
||||
if (GRANDFATHERED_ICONS.includes(app.id)) WARN(`JS icon ${file.name} should be 48x48px (or slightly under) but is instead ${icon[0]}x${icon[1]}px`, {file:appDirRelative+file.url});
|
||||
else ERROR(`JS icon ${file.name} should be 48x48px (or slightly under) but is instead ${icon[0]}x${icon[1]}px`, {file:appDirRelative+file.url});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
let dataNames = [];
|
||||
(app.data||[]).forEach((data)=>{
|
||||
if (!data.name && !data.wildcard) ERROR(`App ${app.id} has a data file with no name`);
|
||||
if (!data.name && !data.wildcard) ERROR(`App ${app.id} has a data file with no name`, {file:metadataFile});
|
||||
if (dataNames.includes(data.name||data.wildcard))
|
||||
ERROR(`App ${app.id} data file ${data.name||data.wildcard} is a duplicate`);
|
||||
ERROR(`App ${app.id} data file ${data.name||data.wildcard} is a duplicate`, {file:metadataFile});
|
||||
dataNames.push(data.name||data.wildcard)
|
||||
allFiles.push({app: app.id, data: (data.name||data.wildcard)});
|
||||
if ('name' in data && 'wildcard' in data)
|
||||
ERROR(`App ${app.id} data file ${data.name} has both name and wildcard`);
|
||||
ERROR(`App ${app.id} data file ${data.name} has both name and wildcard`, {file:metadataFile});
|
||||
if (isGlob(data.name))
|
||||
ERROR(`App ${app.id} data file name ${data.name} contains wildcards`);
|
||||
ERROR(`App ${app.id} data file name ${data.name} contains wildcards`, {file:metadataFile});
|
||||
if (data.wildcard) {
|
||||
if (!isGlob(data.wildcard))
|
||||
ERROR(`App ${app.id} data file wildcard ${data.wildcard} does not actually contains wildcard`);
|
||||
ERROR(`App ${app.id} data file wildcard ${data.wildcard} does not actually contains wildcard`, {file:metadataFile});
|
||||
if (data.wildcard.replace(/\?|\*/g,'') === '')
|
||||
ERROR(`App ${app.id} data file wildcard ${data.wildcard} does not contain regular characters`);
|
||||
ERROR(`App ${app.id} data file wildcard ${data.wildcard} does not contain regular characters`, {file:metadataFile});
|
||||
else if (data.wildcard.replace(/\?|\*/g,'').length < 3)
|
||||
WARN(`App ${app.id} data file wildcard ${data.wildcard} is very broad`);
|
||||
WARN(`App ${app.id} data file wildcard ${data.wildcard} is very broad`, {file:metadataFile});
|
||||
else if (!data.wildcard.includes(app.id))
|
||||
WARN(`App ${app.id} data file wildcard ${data.wildcard} does not include app ID`);
|
||||
WARN(`App ${app.id} data file wildcard ${data.wildcard} does not include app ID`, {file:metadataFile});
|
||||
}
|
||||
let char = (data.name||data.wildcard).match(FORBIDDEN_FILE_NAME_CHARS)
|
||||
if (char) ERROR(`App ${app.id} data file ${data.name||data.wildcard} contains invalid character "${char[0]}"`)
|
||||
if (char) ERROR(`App ${app.id} data file ${data.name||data.wildcard} contains invalid character "${char[0]}"`, {file:metadataFile})
|
||||
if ('storageFile' in data && typeof data.storageFile !== 'boolean')
|
||||
ERROR(`App ${app.id} data file ${data.name||data.wildcard} has non-boolean value for "storageFile"`);
|
||||
ERROR(`App ${app.id} data file ${data.name||data.wildcard} has non-boolean value for "storageFile"`, {file:metadataFile});
|
||||
for (const key in data) {
|
||||
if (!DATA_KEYS.includes(key))
|
||||
ERROR(`App ${app.id} data file ${data.name||data.wildcard} has unknown property "${key}"`);
|
||||
ERROR(`App ${app.id} data file ${data.name||data.wildcard} has unknown property "${key}"`, {file:metadataFile});
|
||||
}
|
||||
});
|
||||
// prefer "appid.json" over "appid.settings.json" (TODO: change to ERROR once all apps comply?)
|
||||
|
@ -256,32 +271,35 @@ apps.forEach((app,appIdx) => {
|
|||
WARN(`App ${app.id} uses data file ${app.id+'.settings.json'}`)*/
|
||||
// settings files should be listed under data, not storage (TODO: change to ERROR once all apps comply?)
|
||||
if (fileNames.includes(app.id+".settings.json"))
|
||||
WARN(`App ${app.id} uses storage file ${app.id+'.settings.json'} instead of data file`)
|
||||
WARN(`App ${app.id} uses storage file ${app.id+'.settings.json'} instead of data file`, {file:metadataFile})
|
||||
if (fileNames.includes(app.id+".json"))
|
||||
WARN(`App ${app.id} uses storage file ${app.id+'.json'} instead of data file`)
|
||||
WARN(`App ${app.id} uses storage file ${app.id+'.json'} instead of data file`, {file:metadataFile})
|
||||
// warn if storage file matches data file of same app
|
||||
dataNames.forEach(dataName=>{
|
||||
const glob = globToRegex(dataName)
|
||||
fileNames.forEach(fileName=>{
|
||||
if (glob.test(fileName)) {
|
||||
if (isGlob(dataName)) WARN(`App ${app.id} storage file ${fileName} matches data wildcard ${dataName}`)
|
||||
else WARN(`App ${app.id} storage file ${fileName} is also listed in data`)
|
||||
if (isGlob(dataName)) WARN(`App ${app.id} storage file ${fileName} matches data wildcard ${dataName}`, {file:metadataFile})
|
||||
else WARN(`App ${app.id} storage file ${fileName} is also listed in data`, {file:metadataFile})
|
||||
}
|
||||
})
|
||||
})
|
||||
//console.log(fileNames);
|
||||
if (isApp && !fileNames.includes(app.id+".app.js")) ERROR(`App ${app.id} has no entrypoint`);
|
||||
if (isApp && !fileNames.includes(app.id+".img")) ERROR(`App ${app.id} has no JS icon`);
|
||||
if (app.type=="widget" && !fileNames.includes(app.id+".wid.js")) ERROR(`Widget ${app.id} has no entrypoint`);
|
||||
if (isApp && !fileNames.includes(app.id+".app.js")) ERROR(`App ${app.id} has no entrypoint`, {file:metadataFile});
|
||||
if (isApp && !fileNames.includes(app.id+".img")) ERROR(`App ${app.id} has no JS icon`, {file:metadataFile});
|
||||
if (app.type=="widget" && !fileNames.includes(app.id+".wid.js")) ERROR(`Widget ${app.id} has no entrypoint`, {file:metadataFile});
|
||||
for (const key in app) {
|
||||
if (!APP_KEYS.includes(key)) ERROR(`App ${app.id} has unknown key ${key}`);
|
||||
if (!APP_KEYS.includes(key)) ERROR(`App ${app.id} has unknown key ${key}`, {file:metadataFile});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Do not allow files from different apps to collide
|
||||
let fileA
|
||||
|
||||
while(fileA=allFiles.pop()) {
|
||||
if (VALID_DUPLICATES.includes(fileA.file))
|
||||
return;
|
||||
break;
|
||||
const nameA = (fileA.file||fileA.data),
|
||||
globA = globToRegex(nameA),
|
||||
typeA = fileA.file?'storage':'data'
|
||||
|
@ -291,9 +309,16 @@ while(fileA=allFiles.pop()) {
|
|||
typeB = fileB.file?'storage':'data'
|
||||
if (globA.test(nameB)||globB.test(nameA)) {
|
||||
if (isGlob(nameA)||isGlob(nameB))
|
||||
ERROR(`App ${fileB.app} ${typeB} file ${nameB} matches app ${fileA.app} ${typeB} file ${nameA}`)
|
||||
ERROR(`App ${fileB.app} ${typeB} file ${nameB} matches app ${fileA.app} ${typeB} file ${nameA}`);
|
||||
else if (fileA.app != fileB.app)
|
||||
WARN(`App ${fileB.app} ${typeB} file ${nameB} is also listed as ${typeA} file for app ${fileA.app}`)
|
||||
WARN(`App ${fileB.app} ${typeB} file ${nameB} is also listed as ${typeA} file for app ${fileA.app}`);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
console.log("==================================");
|
||||
console.log(`${errorCount} errors, ${warningCount} warnings`);
|
||||
console.log("==================================");
|
||||
if (errorCount) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
|
|
@ -10,15 +10,14 @@
|
|||
*/
|
||||
|
||||
|
||||
function Layout(layout, options) {
|
||||
function Layout(layout, options) {
|
||||
this._l = this.l = layout;
|
||||
// Do we have >1 physical buttons?
|
||||
this.physBtns = (process.env.HWVERSION==2) ? 1 : 3;
|
||||
|
||||
this.options = options || {};
|
||||
this.lazy = this.options.lazy || false;
|
||||
|
||||
var btnList;
|
||||
let btnList;
|
||||
if (process.env.HWVERSION!=2) {
|
||||
// no touchscreen, find any buttons in 'layout'
|
||||
btnList = [];
|
||||
|
@ -37,9 +36,9 @@ function Layout(layout, options) {
|
|||
|
||||
if (this.options.btns) {
|
||||
var buttons = this.options.btns;
|
||||
this.b = buttons;
|
||||
if (this.physBtns >= buttons.length) {
|
||||
// enough physical buttons
|
||||
this.b = buttons;
|
||||
let btnHeight = Math.floor(Bangle.appRect.h / this.physBtns);
|
||||
if (this.physBtns > 2 && buttons.length==1)
|
||||
buttons.unshift({label:""}); // pad so if we have a button in the middle
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function p(b,k){function d(h){h.id&&(f[h.id]=h);h.type||(h.type="");h.c&&h.c.forEach(d)}this._l=this.l=b;this.physBtns=2==process.env.HWVERSION?1:3;this.options=k||{};this.lazy=this.options.lazy||!1;if(2!=process.env.HWVERSION){var a=[];function h(m){"btn"==m.type&&a.push(m);m.c&&m.c.forEach(h)}h(b);a.length&&(this.physBtns=0,this.buttons=a,this.selectedButton=-1)}if(this.options.btns)if(this.b=b=this.options.btns,this.physBtns>=b.length){let h=Math.floor(Bangle.appRect.h/
|
||||
function p(b,k){function d(h){h.id&&(f[h.id]=h);h.type||(h.type="");h.c&&h.c.forEach(d)}this._l=this.l=b;this.physBtns=2==process.env.HWVERSION?1:3;this.options=k||{};this.lazy=this.options.lazy||!1;let a;if(2!=process.env.HWVERSION){a=[];function h(m){"btn"==m.type&&a.push(m);m.c&&m.c.forEach(h)}h(b);a.length&&(this.physBtns=0,this.buttons=a,this.selectedButton=-1)}if(this.options.btns)if(b=this.options.btns,this.physBtns>=b.length){this.b=b;let h=Math.floor(Bangle.appRect.h/
|
||||
this.physBtns);for(2<this.physBtns&&1==b.length&&b.unshift({label:""});this.physBtns>b.length;)b.push({label:""});this._l.width=g.getWidth()-8;this._l={type:"h",filly:1,c:[this._l,{type:"v",pad:1,filly:1,c:b.map(m=>(m.type="txt",m.font="6x8",m.height=h,m.r=1,m))}]}}else this._l.width=g.getWidth()-32,this._l={type:"h",c:[this._l,{type:"v",c:b.map(h=>(h.type="btn",h.filly=1,h.width=32,h.r=1,h))}]},a&&a.push.apply(a,this._l.c[1].c);this.setUI();var f=this;d(this._l);this.updateNeeded=!0}function r(b,
|
||||
k,d,a,f){var h=null==b.bgCol?f:g.toColor(b.bgCol);if(h!=f||"txt"==b.type||"btn"==b.type||"img"==b.type||"custom"==b.type){var m=b.c;delete b.c;var c="H"+E.CRC32(E.toJS(b));m&&(b.c=m);delete k[c]||((a[c]=[b.x,b.y,b.x+b.w-1,b.y+b.h-1]).bg=null==f?g.theme.bg:f,d&&(d.push(b),d=null))}if(b.c)for(var l of b.c)r(l,k,d,a,h)}p.prototype.setUI=function(){Bangle.setUI();let b;this.buttons&&(Bangle.setUI({mode:"updown",back:this.options.back},k=>{var d=this.selectedButton,a=this.buttons.length;if(void 0===k&&
|
||||
this.buttons[d])return this.buttons[d].cb();this.buttons[d]&&(delete this.buttons[d].selected,this.render(this.buttons[d]));d=(d+a+k)%a;this.buttons[d]&&(this.buttons[d].selected=1,this.render(this.buttons[d]));this.selectedButton=d}),b=!0);this.options.back&&!b&&Bangle.setUI({mode:"custom",back:this.options.back});if(this.b){function k(d,a){.75<a.time-a.lastTime&&this.b[d].cbl?this.b[d].cbl(a):this.b[d].cb&&this.b[d].cb(a)}Bangle.btnWatches&&Bangle.btnWatches.forEach(clearWatch);Bangle.btnWatches=
|
||||
|
@ -11,4 +11,4 @@ case "v":var h=b.y+(0|b.pad),m=0,c=b.c&&b.c.reduce((e,n)=>e+(0|n.filly),0);c||(h
|
|||
b.h-b.pad);k++;b.c&&b.c.forEach(d=>this.debug(d,k))};p.prototype.update=function(){function b(a){"ram";k[a.type](a);if(a.r&1){var f=a._w;a._w=a._h;a._h=f}a._w=0|Math.max(a._w+(a.pad<<1),0|a.width);a._h=0|Math.max(a._h+(a.pad<<1),0|a.height)}delete this.updateNeeded;var k={txt:function(a){a.font.endsWith("%")&&(a.font="Vector"+Math.round(g.getHeight()*a.font.slice(0,-1)/100));if(a.wrap)a._h=a._w=0;else{var f=g.setFont(a.font).stringMetrics(a.label);a._w=f.width;a._h=f.height}},btn:function(a){a.font&&
|
||||
a.font.endsWith("%")&&(a.font="Vector"+Math.round(g.getHeight()*a.font.slice(0,-1)/100));var f=a.src?g.imageMetrics("function"==typeof a.src?a.src():a.src):g.setFont(a.font||"6x8:2").stringMetrics(a.label);a._h=16+f.height;a._w=20+f.width},img:function(a){var f=g.imageMetrics("function"==typeof a.src?a.src():a.src),h=a.scale||1;a._w=f.width*h;a._h=f.height*h},"":function(a){a._w=0;a._h=0},custom:function(a){a._w=0;a._h=0},h:function(a){a.c.forEach(b);a._h=a.c.reduce((f,h)=>Math.max(f,h._h),0);a._w=
|
||||
a.c.reduce((f,h)=>f+h._w,0);null==a.fillx&&a.c.some(f=>f.fillx)&&(a.fillx=1);null==a.filly&&a.c.some(f=>f.filly)&&(a.filly=1)},v:function(a){a.c.forEach(b);a._h=a.c.reduce((f,h)=>f+h._h,0);a._w=a.c.reduce((f,h)=>Math.max(f,h._w),0);null==a.fillx&&a.c.some(f=>f.fillx)&&(a.fillx=1);null==a.filly&&a.c.some(f=>f.filly)&&(a.filly=1)}},d=this._l;b(d);d.fillx||d.filly?(d.w=Bangle.appRect.w,d.h=Bangle.appRect.h,d.x=Bangle.appRect.x,d.y=Bangle.appRect.y):(d.w=d._w,d.h=d._h,d.x=Bangle.appRect.w-d.w>>1,d.y=
|
||||
Bangle.appRect.y+(Bangle.appRect.h-d.h>>1));this.layout(d)};p.prototype.clear=function(b){b||(b=this._l);g.reset();void 0!==b.bgCol&&g.setBgColor(b.bgCol);g.clearRect(b.x,b.y,b.x+b.w-1,b.y+b.h-1)};exports=p
|
||||
Bangle.appRect.y+(Bangle.appRect.h-d.h>>1));this.layout(d)};p.prototype.clear=function(b){b||(b=this._l);g.reset();void 0!==b.bgCol&&g.setBgColor(b.bgCol);g.clearRect(b.x,b.y,b.x+b.w-1,b.y+b.h-1)};exports=p
|