I've been working on a launcher, and like everyone else, have been creating two separate apps because of the form factor differences (screen/buttons) between Bangle.js 1 and 2. I think that we need a way to make it easier to create single apps that support both models. Obviously, sometimes this is as simple as some if statements checking the hardware version. But when that isn't the case, there has to be a better way to do this where we can create a single app but it will install/run different code depending on the model it is used on instead of maintaining two copies of the same app for that reason.
Below is my recommendation on how we could do this. In an attempt to future proof this, I have included a hypothetical Bangle.js 3 which would have a similar form factor to the real Bangle.js 2 and therefore would be able to use the same code for both models. Under Storage, I added the same supports list to the files used to install that app.
The default value for supports is implicitly all models. This is what you would use for setting, icon, and boot files when it would be the same for all 3 models. When you explicitly list the model(s) in supports, it is only written to Storage on install for that model(s). This would allow for more code reuse and reduce app storage use on the watch.
In the hypothetical launch app below, only one launch.app.js file is written to a BANGLEJS or BANGLEJS2/BANGLEJS3. In the hypothetical welcome app below, only one welcome.app.js file and welcome.boot.js file is written to a BANGLEJS, BANGLEJS2, or BANGLEJS3.
Example of my proposed apps.json format for supporting this recommendation.
{
"id": "launch",
"name": "Launcher (Bangle.js 1, 2, & 3)",
"shortName": "Launcher",
"version": "0.08",
"description": "This is needed by Bangle.js to display a menu allowing you to choose your own applications. You can replace this with a customised launcher.",
"icon": "app.png",
"type": "launch",
"tags": "tool,system,launcher",
"supports": ["BANGLEJS","BANGLEJS2","BANGLEJS3"],
"storage": [
{"supports": ["BANGLEJS"],"name":"launch.app.js","url":"app-b1.js"},
{"supports": ["BANGLEJS2","BANGLEJS3"],"name":"launch.app.js","url":"app.js"}
],
"sortorder": -10
},
{
"id": "welcome",
"name": "Welcome (Bangle.js 1, 2, & 3)",
"shortName": "Welcome",
"version": "0.13",
"description": "Appears at first boot and explains how to use Bangle.js",
"icon": "app.png",
"tags": "start,welcome",
"supports": ["BANGLEJS","BANGLEJS2","BANGLEJS3"],
"allow_emulator": true,
"storage": [
{"supports": ["BANGLEJS"],"name":"welcome.boot.js","url":"boot-b1.js"},
{"supports": ["BANGLEJS"],"name":"welcome.app.js","url":"app-b1.js"},
{"supports": ["BANGLEJS2"],"name":"welcome.boot.js","url":"boot-b2.js"},
{"supports": ["BANGLEJS2"],"name":"welcome.app.js","url":"app-b2.js"},
{"supports": ["BANGLEJS3"],"name":"welcome.boot.js","url":"boot-b3.js"},
{"supports": ["BANGLEJS3"],"name":"welcome.app.js","url":"app-b3.js"},
{"name":"welcome.settings.js","url":"settings.js"},
{"name":"welcome.img","url":"app-icon.js","evaluate":true}
],
"data": [{"name":"welcome.json"}]
}
I hope that I did a good job of explaining this and that others think that this would be a useful improvement. Please let me know if you have any questions or suggestions.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I've been working on a launcher, and like everyone else, have been creating two separate apps because of the form factor differences (screen/buttons) between Bangle.js 1 and 2. I think that we need a way to make it easier to create single apps that support both models. Obviously, sometimes this is as simple as some if statements checking the hardware version. But when that isn't the case, there has to be a better way to do this where we can create a single app but it will install/run different code depending on the model it is used on instead of maintaining two copies of the same app for that reason.
Below is my recommendation on how we could do this. In an attempt to future proof this, I have included a hypothetical Bangle.js 3 which would have a similar form factor to the real Bangle.js 2 and therefore would be able to use the same code for both models. Under Storage, I added the same supports list to the files used to install that app.
The default value for supports is implicitly all models. This is what you would use for setting, icon, and boot files when it would be the same for all 3 models. When you explicitly list the model(s) in supports, it is only written to Storage on install for that model(s). This would allow for more code reuse and reduce app storage use on the watch.
In the hypothetical launch app below, only one launch.app.js file is written to a BANGLEJS or BANGLEJS2/BANGLEJS3. In the hypothetical welcome app below, only one welcome.app.js file and welcome.boot.js file is written to a BANGLEJS, BANGLEJS2, or BANGLEJS3.
Example of my proposed apps.json format for supporting this recommendation.
I hope that I did a good job of explaining this and that others think that this would be a useful improvement. Please let me know if you have any questions or suggestions.