Skip to content

[qmsched] Add day-specific scheduling#4201

Draft
RKBoss6 wants to merge 14 commits intoespruino:masterfrom
RKBoss6:qmsched-final
Draft

[qmsched] Add day-specific scheduling#4201
RKBoss6 wants to merge 14 commits intoespruino:masterfrom
RKBoss6:qmsched-final

Conversation

@RKBoss6
Copy link
Copy Markdown
Contributor

@RKBoss6 RKBoss6 commented Mar 26, 2026

Adds day specific scheduling using a bitmask similar to Alarms, and added a clockInfo for fast switching directly from the clock. Also created a method getQuietMode() that gets the mode active instead of clockinfo, and widgets doing it separately

Copilot AI review requested due to automatic review settings March 26, 2026 17:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds day-specific quiet-mode scheduling and exposes quick mode switching via a new Clock Info entry, while centralizing “current quiet mode” lookup into the qmsched library.

Changes:

  • Implement day-of-week filtering for scheduled quiet-mode changes (bitmask-based).
  • Add a clkinfo module for toggling quiet mode from clocks.
  • Add getMode() helper in lib.js and update the widget to use it.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
apps/qmsched/app.js UI updates to display/edit schedules with day bitmasks and a day picker menu
apps/qmsched/boot.js Boot-time scheduler updated to select next schedule considering day masks
apps/qmsched/clkinfo.js New clockinfo item to view/toggle quiet mode quickly
apps/qmsched/lib.js Adds getMode() accessor for the active quiet mode
apps/qmsched/widget.js Uses qmsched.getMode() when rendering the widget
apps/qmsched/metadata.json Version bump, tags updated, and clkinfo file added to storage list
apps/qmsched/ChangeLog Notes new day-specific scheduling and clkinfo addition

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +216 to +223
menu[B2 ? "Save" : "> Save"] = function() {
if (isNew) scheds.push(getSched());
else scheds[index] = getSched();
save();
showMainMenu();
};
if (!isNew) {
menu[B2 ? "Delete" : "> Delete"] = function() {
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Save label introduced here ("Save" / "> Save") is user-facing but isn’t marked with /*LANG*/ like other strings in this file. Please add translation markers (and keep B2/non-B2 variants consistent).

Suggested change
menu[B2 ? "Save" : "> Save"] = function() {
if (isNew) scheds.push(getSched());
else scheds[index] = getSched();
save();
showMainMenu();
};
if (!isNew) {
menu[B2 ? "Delete" : "> Delete"] = function() {
menu[B2 ? /*LANG*/"Save" : /*LANG*/"> Save"] = function() {
if (isNew) scheds.push(getSched());
else scheds[index] = getSched();
save();
showMainMenu();
};
if (!isNew) {
menu[B2 ? /*LANG*/"Delete" : /*LANG*/"> Delete"] = function() {

Copilot uses AI. Check for mistakes.
Comment on lines +223 to +227
menu[B2 ? "Delete" : "> Delete"] = function() {
scheds.splice(index, 1);
save();
showMainMenu();
};
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Delete label introduced here ("Delete" / "> Delete") is user-facing but isn’t marked with /*LANG*/. Please add translation markers for localization consistency.

Copilot uses AI. Check for mistakes.
Comment on lines 3 to +6
area: "tl",
width: ((require("Storage").readJSON("setting.json", 1) || {}).quiet|0) ? 24 : 0,
draw: function() {
const mode = (require("Storage").readJSON("setting.json", 1) || {}).quiet|0;
const mode = require("qmsched").getMode();
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Widget width is still computed by directly reading setting.json, while draw() now uses require("qmsched").getMode(). Using the same helper for both avoids duplicated logic and keeps widget initialization consistent with future changes to how the active mode is determined.

Copilot uses AI. Check for mistakes.
Comment on lines +172 to +175
function showDaysMenu(mask, onDone) {
let cur = mask;
let menu = {"": {title: "Active Days"}};
menu["< Back"] = () => onDone(cur);
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new menu title/label strings here (eg "Active Days", "< Back") are user-facing but aren’t marked with /*LANG*/ like the rest of this file. Please add translation markers to keep localization consistent.

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +12
let txt="Off";
let img=atob("GBgBAAAAAAAAAAAAABwAABwAAH8AAP+AAf/AA//gA//gA//gB//wA//gA//gA//gA//gA//gA//gABwAAD4AABwAAAgAAAAAAAAA");
if(mode==1){
txt="Alarms";
img=atob("GBgBAAAAAAAAAAgAAP+AA//gB//wD//4D//4H//8H//8AAAAAAAAIADiAADgAADgH/nwH/nwD/P4D/P4B/hAA/zgAPnwAAjgAABA")
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clockinfo get() path builds img by decoding base64 with atob(...) on each call. Since these icons are constant, consider decoding once (module-level consts) and reusing them to reduce allocations/CPU during redraws.

Copilot uses AI. Check for mistakes.
const dayNames = ["Su","Mo","Tu","We","Th","Fr","Sa"];

function formatDays(mask) {
if (!mask || mask === allDays) return "Every day";
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatDays treats a 0 bitmask as "Every day" because of the !mask check. However the scheduler logic treats a 0 mask as "no active days" (won’t ever trigger). Consider distinguishing undefined/missing from 0, and either prevent persisting days:0 or display it as "No days".

Suggested change
if (!mask || mask === allDays) return "Every day";
if (mask == null) return "Every day"; // undefined/null => default to every day
if (mask === 0) return "No days";
if (mask === allDays) return "Every day";

Copilot uses AI. Check for mistakes.
Comment on lines +96 to +100
/**
* Get the active quiet mode
* Returns: (int) active quiet mode
*/
exports.getMode = function(){
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description mentions adding getQuietMode(), but this change introduces getMode() instead. Please align the PR description/changelog with the exported API name (or rename the function) to avoid confusion for consumers.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@RKBoss6 RKBoss6 marked this pull request as draft March 26, 2026 17:45
RKBoss6 and others added 2 commits March 26, 2026 13:45
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@bobrippling
Copy link
Copy Markdown
Collaborator

Drop me an @ when you're happy :)

@RKBoss6
Copy link
Copy Markdown
Contributor Author

RKBoss6 commented Apr 2, 2026

Not sure about these lint errors - from what I can tell, they had long exemptions and are now gone due to edits. Would I re-add those lint exemptions, or try to fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants