1
0
Fork 0

Merge remote-tracking branch 'upstream/master'

master
Hugh Barney 2023-02-01 19:36:59 +00:00
commit b116484cd2
15 changed files with 142 additions and 82 deletions

View File

@ -38,3 +38,6 @@
0.35: Add automatic translation of more strings
0.36: alarm widget moved out of app
0.37: add message input and dated Events
0.38: Display date in locale
When switching 'repeat' from 'Workdays', 'Weekends' to 'Custom' preset Custom menu with previous selection
Display alarm label in delete prompt

View File

@ -40,6 +40,14 @@ function handleFirstDayOfWeek(dow) {
// Check the first day of week and update the dow field accordingly (alarms only!)
alarms.filter(e => e.timer === undefined).forEach(a => a.dow = handleFirstDayOfWeek(a.dow));
function getLabel(e) {
const dateStr = e.date && require("locale").date(new Date(e.date), 1);
return (e.timer
? require("time_utils").formatDuration(e.timer)
: (dateStr ? `${dateStr} ${require("time_utils").formatTime(e.t)}` : require("time_utils").formatTime(e.t) + (e.rp ? ` ${decodeDOW(e)}` : ""))
) + (e.msg ? " " + e.msg : "");
}
function showMainMenu() {
const menu = {
"": { "title": /*LANG*/"Alarms & Timers" },
@ -48,11 +56,7 @@ function showMainMenu() {
};
alarms.forEach((e, index) => {
var label = (e.timer
? require("time_utils").formatDuration(e.timer)
: (e.date ? `${e.date.substring(5,10)} ${require("time_utils").formatTime(e.t)}` : require("time_utils").formatTime(e.t) + (e.rp ? ` ${decodeDOW(e)}` : ""))
) + (e.msg ? " " + e.msg : "");
menu[label] = {
menu[getLabel(e)] = {
value: e.on ? (e.timer ? iconTimerOn : iconAlarmOn) : (e.timer ? iconTimerOff : iconAlarmOff),
onchange: () => setTimeout(e.timer ? showEditTimerMenu : showEditAlarmMenu, 10, e, index)
};
@ -184,7 +188,7 @@ function showEditAlarmMenu(selectedAlarm, alarmIndex, withDate) {
if (!isNew) {
menu[/*LANG*/"Delete"] = () => {
E.showPrompt(/*LANG*/"Are you sure?", { title: /*LANG*/"Delete Alarm" }).then((confirm) => {
E.showPrompt(getLabel(alarm) + "\n" + /*LANG*/"Are you sure?", { title: /*LANG*/"Delete Alarm" }).then((confirm) => {
if (confirm) {
alarms.splice(alarmIndex, 1);
saveAndReload();
@ -264,7 +268,7 @@ function showEditRepeatMenu(repeat, dow, dowChangeCallback) {
},
/*LANG*/"Custom": {
value: isCustom ? decodeDOW({ rp: true, dow: dow }) : false,
onchange: () => setTimeout(showCustomDaysMenu, 10, isCustom ? dow : EVERY_DAY, dowChangeCallback, originalRepeat, originalDow)
onchange: () => setTimeout(showCustomDaysMenu, 10, dow, dowChangeCallback, originalRepeat, originalDow)
}
};
@ -372,7 +376,7 @@ function showEditTimerMenu(selectedTimer, timerIndex) {
if (!keyboard) delete menu[/*LANG*/"Message"];
if (!isNew) {
menu[/*LANG*/"Delete"] = () => {
E.showPrompt(/*LANG*/"Are you sure?", { title: /*LANG*/"Delete Timer" }).then((confirm) => {
E.showPrompt(getLabel(timer) + "\n" + /*LANG*/"Are you sure?", { title: /*LANG*/"Delete Timer" }).then((confirm) => {
if (confirm) {
alarms.splice(timerIndex, 1);
saveAndReload();

View File

@ -2,7 +2,7 @@
"id": "alarm",
"name": "Alarms & Timers",
"shortName": "Alarms",
"version": "0.37",
"version": "0.38",
"description": "Set alarms and timers on your Bangle",
"icon": "app.png",
"tags": "tool,alarm",

View File

@ -1,2 +1,3 @@
0.01: First version
0.02: Support BangleJS2
0.03: Added threshold

View File

@ -6,6 +6,8 @@ The first stage of charging Li-ion ends at ~80% capacity when the charge voltage
This app has no UI and no configuration. To disable the app, you have to uninstall it.
New in v0.03: before the very first buzz, the average value after the peak is written to chargent.json and used as threshold for future charges. This reduces the time spent in the second charge stage.
Side notes
- Full capacity is reached after charge current drops to an insignificant level. This is quite some time after charge voltage reached its peak / `E.getBattery()` returns 100.
- This app starts buzzing some time after `E.getBattery()` returns 100 (~15min on my watch), and at least 5min after the peak to account for noise.

View File

@ -6,20 +6,28 @@
if (charging) {
if (!id) {
var max = 0;
var count = 0;
var cnt = 0;
var sum = 0;
var lim = (require('Storage').readJSON('chargent.json', true) || {}).limit || 0;
id = setInterval(() => {
var battlvl = analogRead(pin);
if (max < battlvl) {
max = battlvl;
count = 0;
var val = analogRead(pin);
if (max < val) {
max = val;
cnt = 1;
sum = val;
} else {
count++;
if (10 <= count) { // 10 * 30s == 5 min // TODO ? customizable
cnt++;
sum += val;
}
if (10 < cnt || (lim && lim <= max)) { // 10 * 30s == 5 min // TODO ? customizable
if (!lim) {
lim = sum / cnt;
require('Storage').writeJSON('chargent.json', {limit: lim});
}
// TODO ? customizable
Bangle.buzz(500);
setTimeout(() => Bangle.buzz(500), 1000);
}
}
}, 30*1000);
}
} else {

View File

@ -1,6 +1,6 @@
{ "id": "chargent",
"name": "Charge Gently",
"version": "0.02",
"version": "0.03",
"description": "When charging, reminds you to disconnect the watch to prolong battery life.",
"icon": "icon.png",
"type": "bootloader",
@ -9,5 +9,8 @@
"readme": "README.md",
"storage": [
{"name": "chargent.boot.js", "url": "boot.js"}
],
"data": [
{"name": "chargent.json"}
]
}

View File

@ -1,3 +1,4 @@
0.01: First release
0.02: Move translations to locale module (removed watch settings, now pick language in Bangle App Loader, More..., Settings)
0.03: Change for fast loading, use widget_utils to hide widgets
0.04: Add animation when display changes

View File

@ -16,7 +16,6 @@ Most translations are taken from the original Fuzzy Text International code.
## TODO
* Bold hour word (as the pebble version has)
* Animation when changing time?
## References
Based on Pebble app Fuzzy Text International: https://github.com/hallettj/Fuzzy-Text-International

View File

@ -33,13 +33,17 @@
]
};
let text_scale = 3.5;
let text_scale = 4;
let timeout = 2.5*60;
let drawTimeout;
let animInterval;
let time_string = "";
let time_string_old = "";
let time_string_old_wrapped = "";
let loadSettings = function() {
settings = require("Storage").readJSON(SETTINGS_FILE,1)|| {'showWidgets': false};
}
};
let queueDraw = function(seconds) {
let millisecs = seconds * 1000;
@ -48,10 +52,7 @@ let queueDraw = function(seconds) {
drawTimeout = undefined;
draw();
}, millisecs - (Date.now() % millisecs));
}
const h = g.getHeight();
const w = g.getWidth();
};
let getTimeString = function(date) {
let segment = Math.round((date.getMinutes()*60 + date.getSeconds() + 1)/300);
@ -63,18 +64,47 @@ let getTimeString = function(date) {
f_string = f_string.replace('$2', fuzzy_string.hours[(hour + 1) % 12]);
}
return f_string;
}
};
let draw = function() {
let time_string = getTimeString(new Date()).replace('*', '');
time_string = getTimeString(new Date()).replace('*', '');
//print(time_string);
g.setFont('Vector', (h-24*2)/text_scale);
g.setFontAlign(0, 0);
g.clearRect(0, 24, w, h-24);
g.setColor(g.theme.fg);
g.drawString(g.wrapString(time_string, w).join("\n"), w/2, h/2);
queueDraw(timeout);
if (time_string != time_string_old) {
g.setFont('Vector', R.h/text_scale).setFontAlign(0, 0);
animate(3);
}
queueDraw(timeout);
};
let animate = function(step) {
if (animInterval) clearInterval(animInterval);
let time_string_new_wrapped = g.wrapString(time_string, R.w).join("\n");
slideX = 0;
animInterval = setInterval(function() {
let time_start = getTime()
//blank old time
g.setColor(g.theme.bg);
g.drawString(time_string_old_wrapped, R.x + R.w/2 + slideX, R.y + R.h/2);
g.drawString(time_string_new_wrapped, R.x - R.w/2 + slideX, R.y + R.h/2);
g.setColor(g.theme.fg);
slideX += step;
let stop = false;
if (slideX>=R.w) {
slideX=R.w;
stop = true;
}
//draw shifted new time
g.drawString(time_string_old_wrapped, R.x + R.w/2 + slideX, R.y + R.h/2);
g.drawString(time_string_new_wrapped, R.x - R.w/2 + slideX, R.y + R.h/2);
if (stop) {
time_string_old = time_string;
clearInterval(animInterval);
animInterval=undefined;
time_string_old_wrapped = time_string_new_wrapped;
}
print(Math.round((getTime() - time_start)*1000))
}, 30);
};
g.clear();
loadSettings();
@ -95,6 +125,8 @@ Bangle.setUI({
// Called to unload all of the clock app
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = undefined;
if (animInterval) clearInterval(animInterval);
animInterval = undefined;
require('widget_utils').show(); // re-show widgets
}
});
@ -106,5 +138,6 @@ if (settings.showWidgets) {
require("widget_utils").swipeOn(); // hide widgets, make them visible with a swipe
}
R = Bangle.appRect;
draw();
}

View File

@ -2,7 +2,7 @@
"id":"fuzzyw",
"name":"Fuzzy Text Clock",
"shortName": "Fuzzy Text",
"version": "0.03",
"version": "0.04",
"description": "An imprecise clock for when you're not in a rush",
"readme": "README.md",
"icon":"fuzzyw.png",

View File

@ -1 +1,2 @@
0.01: First public version
0.02: Disable screen lock when breathing

View File

@ -2,7 +2,7 @@
A minimalistic app that will help you practive breathing.
Author: Written by pancake in 2022, powered by insomnia
Author: Written by pancake in 2022, updated in 2023, powered by insomnia
## Features
@ -10,6 +10,7 @@ Author: Written by pancake in 2022, powered by insomnia
* [x] Tap to start
* [x] Subtle vibrations
* [x] Drag to pause breathing
* [x] Dont lock screen while breathing
* [ ] Automatic buzz every hour during day
## Screenshots

View File

@ -14,6 +14,7 @@ var mode = 0;
var sin = 0;
var dragged = 0;
var lastTime = Date.now();
function breath(t) {
var r = Math.abs(Math.sin(t / 100)) * w2;
g.fillCircle(w/2,h/2, r);
@ -68,6 +69,9 @@ function main() {
return;
}
started = true;
Bangle.setLCDPower(1);
Bangle.setLocked(0);
Bangle.setLCDTimeout(0);
animateCircle();
Bangle.buzz(40);
}
@ -81,7 +85,7 @@ function startBreathing() {
var cicles = 3;
g.setFont("Vector", fs);
var interval = setInterval(function() {
function breathTime() {
if (lastTime + 10 > Date.now()) {
return;
}
@ -120,6 +124,6 @@ if (lastTime + 10 > Date.now()) {
Bangle.showClock();
}
dragged = 0;
}, 4);
}
var interval = setInterval(breathTime, 4);
}

View File

@ -2,7 +2,7 @@
"id": "inspire",
"name": "Inspire Breathing",
"shortName": "Inspire",
"version": "0.01",
"version": "0.02",
"description": "exercise breathing every now and then",
"icon": "app-icon.png",
"tags": "tools,health",