mirror of https://github.com/espruino/BangleApps
Merge branch 'master' into baroalarm_v0.02
commit
2f119b3d08
|
@ -243,6 +243,7 @@ and which gives information about the app for the Launcher.
|
|||
"screenshots" : [ { url:"screenshot.png" } ], // optional screenshot for app
|
||||
"type":"...", // optional(if app) -
|
||||
// 'app' - an application
|
||||
// 'clock' - a clock - required for clocks to automatically start
|
||||
// 'widget' - a widget
|
||||
// 'launch' - replacement launcher app
|
||||
// 'bootloader' - code that runs at startup only
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jshint/2.11.0/jshint.min.js"></script>
|
||||
<p>Type your javascript code here</p>
|
||||
<p><textarea id="custom-js"></textarea></p>
|
||||
<p>Then click <button id="upload" class="btn btn-primary">Upload</button></p>
|
||||
<p>Then click <button id="upload" class="btn btn-primary">Upload</button> <span id="btninfo" style="color:orange"></span></p>
|
||||
<script>
|
||||
const item = "custom.boot.js";
|
||||
const id = "custom-js";
|
||||
const sample = "//Bangle.setOptions({wakeOnBTN2:false});";
|
||||
var localeModule = null;
|
||||
var customBootCode = null;
|
||||
var editor = {};
|
||||
|
||||
if (localStorage.getItem(item) === null) {
|
||||
|
@ -48,15 +48,30 @@
|
|||
gutters: ["CodeMirror-linenumbers", "CodeMirror-lint-markers"],
|
||||
lineNumbers: true
|
||||
});
|
||||
function hasWarnings() {
|
||||
return editor.state.lint.marked.length!=0;
|
||||
}
|
||||
|
||||
editor.on("change", function() {
|
||||
setTimeout(function() {
|
||||
if (hasWarnings()) {
|
||||
document.getElementById("btninfo").innerHTML = "There are warnings in the code to be uploaded";
|
||||
document.getElementById("upload").classList.add("disabled");
|
||||
} else {
|
||||
document.getElementById("btninfo").innerHTML = "";
|
||||
document.getElementById("upload").classList.remove("disabled");
|
||||
}
|
||||
}, 500);
|
||||
})
|
||||
|
||||
document.getElementById("upload").addEventListener("click", function() {
|
||||
if (!editor.state.lint.marked.length) {
|
||||
localeModule = editor.getValue();
|
||||
localStorage.setItem(item, localeModule);
|
||||
sendCustomizedApp({
|
||||
storage: [{ name: item, content: localeModule }]
|
||||
});
|
||||
}
|
||||
if (!hasWarnings()) {
|
||||
customBootCode = editor.getValue();
|
||||
localStorage.setItem(item, customBootCode);
|
||||
sendCustomizedApp({
|
||||
storage: [{ name: item, content: customBootCode }]
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"id": "gbridge",
|
||||
"name": "Gadgetbridge",
|
||||
"version": "0.26",
|
||||
"description": "(NOT RECOMMENDED) Displays Gadgetbridge notifications from Android. Please use the 'Android' Bangle.js app instead.",
|
||||
"description": "(NOT RECOMMENDED) Displays Gadgetbridge notifications from Android. Please use the 'Android Integration' Bangle.js app instead.",
|
||||
"icon": "app.png",
|
||||
"type": "widget",
|
||||
"tags": "tool,system,android,widget",
|
||||
|
|
|
@ -35,5 +35,6 @@
|
|||
Allow repeat to be switched Off, so there is no buzzing repetition.
|
||||
Also gave the widget a pixel more room to the right
|
||||
0.23: Change message colors to match current theme instead of using green
|
||||
Now attempt to use Large/Big/Medium fonts, and allow minimum font size to be configured
|
||||
Now attempt to use Large/Big/Medium fonts, and allow minimum font size to be configured
|
||||
0.24: Remove left-over debug statement
|
||||
0.25: Fix widget memory usage issues if message received and watch repeatedly calls Bangle.drawWidgets (fix #1550)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "messages",
|
||||
"name": "Messages",
|
||||
"version": "0.24",
|
||||
"version": "0.25",
|
||||
"description": "App to display notifications from iOS and Gadgetbridge/Android",
|
||||
"icon": "app.png",
|
||||
"type": "app",
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
WIDGETS["messages"]={area:"tl", width:0, iconwidth:24,
|
||||
draw:function() {
|
||||
// If we had a setTimeout queued from the last time we were called, remove it
|
||||
if (WIDGETS["messages"].i) {
|
||||
clearTimeout(WIDGETS["messages"].i);
|
||||
delete WIDGETS["messages"].i;
|
||||
}
|
||||
Bangle.removeListener('touch', this.touch);
|
||||
if (!this.width) return;
|
||||
var c = (Date.now()-this.t)/1000;
|
||||
|
@ -11,7 +16,7 @@ draw:function() {
|
|||
this.l = Date.now();
|
||||
WIDGETS["messages"].buzz(); // buzz every 4 seconds
|
||||
}
|
||||
setTimeout(()=>WIDGETS["messages"].draw(), 1000);
|
||||
WIDGETS["messages"].i=setTimeout(()=>WIDGETS["messages"].draw(), 1000);
|
||||
if (process.env.HWVERSION>1) Bangle.on('touch', this.touch);
|
||||
},show:function(quiet) {
|
||||
WIDGETS["messages"].t=Date.now(); // first time
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
0.01: New App!
|
|
@ -0,0 +1,15 @@
|
|||
# Power manager
|
||||
|
||||
Manages settings for charging. You can set a warning threshold to be able to disconnect the charger at a given percentage. Also allows to set the battery calibration offset.
|
||||
|
||||
## Internals
|
||||
|
||||
Battery calibration offset is set by writing `batFullVoltage` in setting.json
|
||||
|
||||
## TODO
|
||||
|
||||
* Optionally keep battery history and show as graph
|
||||
|
||||
## Creator
|
||||
|
||||
[halemmerich](https://github.com/halemmerich)
|
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -0,0 +1,29 @@
|
|||
(function() {
|
||||
var settings = Object.assign(
|
||||
require('Storage').readJSON("powermanager.default.json", true) || {},
|
||||
require('Storage').readJSON("powermanager.json", true) || {}
|
||||
);
|
||||
|
||||
if (settings.warnEnabled){
|
||||
print("Charge warning enabled");
|
||||
var chargingInterval;
|
||||
|
||||
function handleCharging(charging){
|
||||
if (charging){
|
||||
if (chargingInterval) clearInterval(chargingInterval);
|
||||
chargingInterval = setInterval(()=>{
|
||||
if (E.getBattery() > settings.warn){
|
||||
Bangle.buzz(1000);
|
||||
}
|
||||
}, 10000);
|
||||
}
|
||||
if (chargingInterval && !charging){
|
||||
clearInterval(chargingInterval);
|
||||
chargingInterval = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
Bangle.on("charging",handleCharging);
|
||||
handleCharging(Bangle.isCharging());
|
||||
}
|
||||
})();
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"warnEnabled": false,
|
||||
"warn": 96
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"id": "powermanager",
|
||||
"name": "Power Manager",
|
||||
"shortName": "Power Manager",
|
||||
"version": "0.01",
|
||||
"description": "Allow configuration of warnings and thresholds for battery charging and display.",
|
||||
"icon": "app.png",
|
||||
"type": "bootloader",
|
||||
"tags": "tool",
|
||||
"supports": ["BANGLEJS2"],
|
||||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"powermanager.boot.js","url":"boot.js"},
|
||||
{"name":"powermanager.settings.js","url":"settings.js"},
|
||||
{"name":"powermanager.default.json","url":"default.json"}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
(function(back) {
|
||||
var systemsettings = require("Storage").readJSON("setting.json") || {};
|
||||
|
||||
function writeSettings(key, value) {
|
||||
var s = require('Storage').readJSON(FILE, true) || {};
|
||||
s[key] = value;
|
||||
require('Storage').writeJSON(FILE, s);
|
||||
readSettings();
|
||||
}
|
||||
|
||||
function readSettings() {
|
||||
settings = Object.assign(
|
||||
require('Storage').readJSON("powermanager.default.json", true) || {},
|
||||
require('Storage').readJSON(FILE, true) || {}
|
||||
);
|
||||
}
|
||||
|
||||
var FILE = "powermanager.json";
|
||||
var settings;
|
||||
readSettings();
|
||||
|
||||
var mainmenu = {
|
||||
'': {
|
||||
'title': 'Power Manager'
|
||||
},
|
||||
'< Back': back,
|
||||
'Charge warning': function() {
|
||||
E.showMenu(submenu_chargewarn);
|
||||
},
|
||||
'Calibrate': function() {
|
||||
E.showMenu(submenu_calibrate);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function roundToDigits(number, stepsize) {
|
||||
return Math.round(number / stepsize) * stepsize;
|
||||
}
|
||||
|
||||
function getCurrentVoltageDirect() {
|
||||
return (analogRead(D3) + analogRead(D3) + analogRead(D3) + analogRead(D3)) / 4;
|
||||
}
|
||||
|
||||
var stepsize = 0.0002;
|
||||
var full = 0.32;
|
||||
|
||||
function getInitialCalibrationOffset() {
|
||||
return roundToDigits(systemsettings.batFullVoltage - full, stepsize) || 0;
|
||||
}
|
||||
|
||||
|
||||
var submenu_calibrate = {
|
||||
'': {
|
||||
title: "Calibrate"
|
||||
},
|
||||
'< Back': function() {
|
||||
E.showMenu(mainmenu);
|
||||
},
|
||||
'Offset': {
|
||||
min: -0.05,
|
||||
max: 0.05,
|
||||
step: stepsize,
|
||||
value: getInitialCalibrationOffset(),
|
||||
format: v => roundToDigits(v, stepsize).toFixed((""+stepsize).length - 2),
|
||||
onchange: v => {
|
||||
print(typeof v);
|
||||
systemsettings.batFullVoltage = v + full;
|
||||
require("Storage").writeJSON("setting.json", systemsettings);
|
||||
}
|
||||
},
|
||||
'Auto': function() {
|
||||
var newVoltage = getCurrentVoltageDirect();
|
||||
E.showAlert("Please charge fully before auto setting").then(() => {
|
||||
E.showPrompt("Set current charge as full").then((r) => {
|
||||
if (r) {
|
||||
systemsettings.batFullVoltage = newVoltage;
|
||||
require("Storage").writeJSON("setting.json", systemsettings);
|
||||
//reset value shown in menu to the newly set one
|
||||
submenu_calibrate.Offset.value = getInitialCalibrationOffset();
|
||||
E.showMenu(mainmenu);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
'Clear': function() {
|
||||
E.showPrompt("Clear charging offset?").then((r) => {
|
||||
if (r) {
|
||||
delete systemsettings.batFullVoltage;
|
||||
require("Storage").writeJSON("setting.json", systemsettings);
|
||||
//reset value shown in menu to the newly set one
|
||||
submenu_calibrate.Offset.value = getInitialCalibrationOffset();
|
||||
E.showMenu(mainmenu);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var submenu_chargewarn = {
|
||||
'': {
|
||||
title: "Charge warning"
|
||||
},
|
||||
'< Back': function() {
|
||||
E.showMenu(mainmenu);
|
||||
},
|
||||
'Enabled': {
|
||||
value: !!settings.warnEnabled,
|
||||
format: v => settings.warnEnabled ? "On" : "Off",
|
||||
onchange: v => {
|
||||
writeSettings("warnEnabled", v);
|
||||
}
|
||||
},
|
||||
'Percentage': {
|
||||
min: 80,
|
||||
max: 100,
|
||||
step: 2,
|
||||
value: settings.warn,
|
||||
format: v => v + "%",
|
||||
onchange: v => {
|
||||
writeSettings("warn", v);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
E.showMenu(mainmenu);
|
||||
})
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "widbaroalarm",
|
||||
"name": "Barometer alarm widget",
|
||||
"shortName": "Barometer alarm",
|
||||
"name": "Barometer Alarm Widget",
|
||||
"shortName": "Barometer Alarm",
|
||||
"version": "0.02",
|
||||
"description": "A widget that can alarm on when the pressure reaches defined thresholds.",
|
||||
"icon": "widget.png",
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
0.01: Simple new widget!
|
|
@ -0,0 +1,22 @@
|
|||
# Widget Name
|
||||
|
||||
The days left in month widget is simple and just prints the number of days left in the month in the top left corner.
|
||||
The idea is to encourage people to keep track of time and keep goals they may have for the month.
|
||||
|
||||
## Usage
|
||||
|
||||
Hopefully you just have to Install it and it'll work. Customizing the location would just be changing tl to tr.
|
||||
|
||||
## Features
|
||||
|
||||
* Shows days left in month
|
||||
* Only updates at midnight.
|
||||
|
||||
|
||||
## Requests
|
||||
|
||||
Complaints,compliments,problems,suggestions,annoyances,bugs, and all other feedback can be filed at [this repo](https://github.com/N-Onorato/BangleApps)
|
||||
|
||||
## Creator
|
||||
|
||||
Nick
|
|
@ -0,0 +1,14 @@
|
|||
{ "id": "widmnth",
|
||||
"name": "Days left in month widget",
|
||||
"shortName":"Month Countdown",
|
||||
"version":"0.01",
|
||||
"description": "A simple widget that displays the number of days left in the month.",
|
||||
"icon": "widget.png",
|
||||
"type": "widget",
|
||||
"tags": "widget,date,time,countdown,month",
|
||||
"supports" : ["BANGLEJS","BANGLEJS2"],
|
||||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"widmnth.wid.js","url":"widget.js"}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
|
||||
(() => {
|
||||
var days_left;
|
||||
var clearCode;
|
||||
|
||||
function getDaysLeft(day) {
|
||||
let year = day.getMonth() == 11 ? day.getFullYear() + 1 : day.getFullYear(); // rollover if december.
|
||||
next_month = new Date(year, (day.getMonth() + 1) % 12, 1, 0, 0, 0);
|
||||
let days_left = Math.floor((next_month - day) / 86400000); // ms left in month divided by ms in a day
|
||||
return days_left;
|
||||
}
|
||||
|
||||
function getTimeTilMidnight(now) {
|
||||
let midnight = new Date(now.getTime());
|
||||
midnight.setHours(23);
|
||||
midnight.setMinutes(59);
|
||||
midnight.setSeconds(59);
|
||||
midnight.setMilliseconds(999);
|
||||
return (midnight - now) + 1;
|
||||
}
|
||||
|
||||
function update() {
|
||||
let now = new Date();
|
||||
days_left = getDaysLeft(now);
|
||||
let ms_til_midnight = getTimeTilMidnight(now);
|
||||
clearCode = setTimeout(update, ms_til_midnight);
|
||||
}
|
||||
|
||||
function draw() {
|
||||
g.reset();
|
||||
g.setFont("4x6", 3);
|
||||
if(!clearCode) update(); // On first run calculate days left and setup interval to update state.
|
||||
g.drawString(days_left < 10 ? "0" + days_left : days_left.toString(), this.x + 2, this.y + 4);
|
||||
}
|
||||
|
||||
// add your widget
|
||||
WIDGETS.widmonthcountdown={
|
||||
area:"tl", // tl (top left), tr (top right), bl (bottom left), br (bottom right)
|
||||
width: 24,
|
||||
draw:draw
|
||||
};
|
||||
})();
|
Binary file not shown.
After Width: | Height: | Size: 470 B |
Loading…
Reference in New Issue