Change icon, rename internal timer, display running timer on app restart

Start timer on button press
Invert icon, update metadata
Update ChangeLog
pull/3691/head
vovcia 2024-12-14 18:08:23 +01:00
parent ad24e33a81
commit 80173b9851
4 changed files with 39 additions and 29 deletions

View File

@ -1 +1,2 @@
0.01: First release
0.01: First release
0.02: Fix icon, utilize sched, show running timer on app relaunch

View File

@ -1 +1 @@
atob("LjCI/hsbGxsbGxsbGxsbGxsbGwcHBwccHBwcHBwcHBwHBxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsHBwccHR0eHh4PDw8PDx4eHh0cBwcHGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsHBxwdHg8PDw8PDw8eHg8PDw8PDx4dHAcbGxsHGxsbGxsbGxsbGxsbGxsbGxsHHB0eDw8PHh0cGxoaGhoaGxwdHg8PDx4dHAcbGxsbGxsbGxsbGxsbGxsbGwcHHR4PDx4dGxkZGRkZGRkZGRkYGRkbHR4PDx4dBxsbGxsbGwcbGxsbGxsbGwccHQ8PHh0bGRkaGhsbGxoaGhoaGRkZGRkaHB4PDx0cBxsbGxsHGxsbGxsbGwccHg8PHhsZGRsHBxsbGhoaGhkZGRkZGRkZGRkaHg8PHhwHBwcbGxsbGxsbGwccHg8eHBkZGxwHGxoaGxoZBx4aGRsbGRkZGRkZGRkcHg8eHAcbGxsHGxsbGwccHg8eHBkaBxwHGxoZGx4bGR0dGRkdBxkZGRkZGRkZGQceHh4cBxsbBwcbGxscHg8PHBkaBwcbGhkZGRseGhkcHhkZHgcZGRkZGRkZGRkZBx4eHQcbBwcbGxsHHQ8PHBkaBwcaGRkZGRkZHR0ZGR0cGBseGRkZGRkZGRkZGRkcHh4dBwcHGxsHHA8PHRkaBxsaGRkZGRkZGQcdGRkdHBgbHhoZGRkZGRkZGRkZGh0eHhwHBxsbBx4PHhoZGxsaGRkZGRkZGRkcBxkaHBoZBxwZGRkZGRkZGRkZGRkaHR4dBwcbBx0PDxwZGwcaGRkZGRkZGRkZGRkZGRkZGRk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RkZGRgYGBgYGBgYGBkZGRkZGhoaGhsbGxsbGw==")
require("heatshrink").decompress(atob("mEwgIKHgwFKo0gAofmsALEGR0H/+f//+gEP/4ACAoXAn4FDAQn8g0DAoX4g0BAoXx4E4AoXhAoN/8EP4AzBn/4h/IC4M//kPzgjBz/+h+MAoMfj0PNYUfh4FDh8HAo0wg/454RBmBDBAoRnBCIIjCAAMPF4IFDHYOIgEBj5HBzkAIIPAIIIFBn4hBLIU+AoPgwEQvwFBOIX8CgP5w0RAoSJC/AsB/0EJwIgB/+Aj/wAoN/VgPgQwQFBwBKCXAQWBAAfgAoocCAoQcCAAPAj7XEcYIABcYLIBAAJBBA=="))

View File

@ -44,14 +44,21 @@ function drawTime() {
function startTimer() {
if (timerRunning) return;
if (timeRemaining == 0) return;
timerRunning = true;
// Save the default duration on timer start
timerDuration = timeRemaining;
saveDefaultDuration();
scheduleTimer();
// Start the secondary timer to update the display
setInterval(updateDisplay, 1000);
}
function scheduleTimer() {
// Schedule a new timer using the sched library
require("sched").setAlarm("mytimer", {
require("sched").setAlarm("ateatimer", {
msg: "Tea is ready!",
timer: timeRemaining * 1000, // Convert to milliseconds
vibrate: ".." // Default vibration pattern
@ -59,14 +66,11 @@ function startTimer() {
// Ensure the scheduler updates
require("sched").reload();
// Start the secondary timer to update the display
setInterval(updateDisplay, 1000);
}
function resetTimer() {
// Cancel the existing timer
require("sched").setAlarm("mytimer", undefined);
require("sched").setAlarm("ateatimer", undefined);
require("sched").reload();
timerRunning = false;
@ -75,25 +79,21 @@ function resetTimer() {
}
function adjustTime(amount) {
if (-amount > timeRemaining) {
// Return if result will be negative
return;
}
timeRemaining += amount;
timeRemaining = Math.max(1, timeRemaining); // Ensure time doesn't go negative
print(timeRemaining);
timeRemaining = Math.max(0, timeRemaining); // Ensure time doesn't go negative
if (timerRunning) {
// Update the existing timer with the new remaining time
let alarm = require("sched").getAlarm("mytimer");
let alarm = require("sched").getAlarm("ateatimer");
if (alarm) {
// Cancel the current alarm
require("sched").setAlarm("mytimer", undefined);
require("sched").setAlarm("ateatimer", undefined);
// Set a new alarm with the updated time
require("sched").setAlarm("mytimer", {
msg: "Tea is ready!",
timer: timeRemaining * 1000, // Convert to milliseconds
vibrate: ".." // Default vibration pattern
});
// Reload the scheduler to apply changes
require("sched").reload();
scheduleTimer();
}
}
@ -120,13 +120,11 @@ function handleTouch(x, y) {
// Function to update the display every second
function updateDisplay() {
if (timerRunning) {
let alarm = require("sched").getAlarm("mytimer");
if (alarm) {
timeRemaining = Math.ceil(require("sched").getTimeToAlarm(alarm) / 1000);
}
let alarm = require("sched").getAlarm("ateatimer");
timeRemaining = Math.floor(require("sched").getTimeToAlarm(alarm) / 1000);
drawTime();
if (timeRemaining <= 0) {
timeRemaining = 0
timeRemaining = 0;
clearInterval(updateDisplay);
timerRunning = false;
}
@ -135,7 +133,11 @@ function updateDisplay() {
// Handle physical button press for resetting timer
setWatch(() => {
resetTimer();
if (timerRunning) {
resetTimer();
} else {
startTimer();
}
}, BTN1, { repeat: true, edge: "falling" });
// Handle touch
@ -143,5 +145,12 @@ Bangle.on("touch", (zone, xy) => {
handleTouch(xy.x, xy.y, false);
});
// Draw the initial timer display
drawTime();
let isRunning = require("sched").getAlarm("ateatimer");
if (isRunning) {
timerRunning = true;
// Start the timer to update the display
setInterval(updateDisplay, 1000);
} else {
// Draw the initial timer display
drawTime();
}

View File

@ -2,8 +2,8 @@
"name": "A Tea Timer",
"shortName":"A Tea Timer",
"icon": "app.png",
"version":"0.01",
"description": "Simple app for setting countdown timers for tea. Press up and down to change time, and touch time to start counting. Button will stop countdown and reset counter to last used value.",
"version":"0.02",
"description": "Simple app for setting timers for tea. Touch up and down to change time, and time or button to start counting. When timer is running, button will stop timer and reset counter to last used value.",
"tags": "timer",
"supports": ["BANGLEJS2"],
"storage": [