rep: add recorder functionality

pull/2851/head
Rob Pilling 2023-07-01 11:55:00 +01:00
parent 7b760ae803
commit 98597073ef
4 changed files with 55 additions and 8 deletions

View File

@ -7,6 +7,7 @@ You can rewind, fast-forward and play/pause with the control buttons.
# Todo # Todo
- [ ] Recorder functionality - [X] Recorder functionality
- [ ] Recorder toggle functionality
- [ ] Fastload: scoping, unregister layout handlers etc - [ ] Fastload: scoping, unregister layout handlers etc
- [ ] Swipe handlers as well as "<<" / ">>" buttons - [ ] Swipe handlers as well as "<<" / ">>" buttons

View File

@ -246,8 +246,20 @@
}; };
buzz(); buzz();
}; };
var init = function () {
g.clear();
drawRep_1();
Bangle.drawWidgets();
};
Bangle.loadWidgets(); Bangle.loadWidgets();
g.clear(); if (settings.record && WIDGETS["recorder"]) {
drawRep_1(); WIDGETS["recorder"]
Bangle.drawWidgets(); .setRecording(true)
.then(init);
if (settings.recordStopOnExit)
E.on('kill', function () { return WIDGETS["recorder"].setRecording(false); });
}
else {
init();
}
} }

View File

@ -1,4 +1,6 @@
type RepSettings = { type RepSettings = {
record: boolean,
recordStopOnExit: boolean,
stepMs: number, stepMs: number,
}; };
@ -308,10 +310,23 @@ const buzzNewRep = () => {
buzz(); buzz();
}; };
const init = () => {
g.clear();
drawRep();
Bangle.drawWidgets();
};
Bangle.loadWidgets(); Bangle.loadWidgets();
if (settings.record && WIDGETS["recorder"]) {
(WIDGETS["recorder"] as RecorderWidget)
.setRecording(true)
.then(init);
if (settings.recordStopOnExit)
E.on('kill', () => (WIDGETS["recorder"] as RecorderWidget).setRecording(false));
} else {
init();
}
g.clear();
drawRep();
Bangle.drawWidgets();
} }

View File

@ -3,6 +3,8 @@
const storage = require("Storage") const storage = require("Storage")
const settings = (storage.readJSON(SETTINGS_FILE, true) || {}) as RepSettings; const settings = (storage.readJSON(SETTINGS_FILE, true) || {}) as RepSettings;
settings.record ??= false;
settings.recordStopOnExit ??= false;
settings.stepMs ??= 5 * 1000; settings.stepMs ??= 5 * 1000;
const save = () => { const save = () => {
@ -25,5 +27,22 @@
}, },
}; };
if (global["WIDGETS"] && WIDGETS["recorder"]) {
menu[/*LANG*/"Record activity"] = {
value: !!settings.record,
onchange: (v: boolean) => {
settings.record = v;
save();
}
};
menu[/*LANG*/"Stop record on exit"] = {
value: !!settings.recordStopOnExit,
onchange: (v: boolean) => {
settings.recordStopOnExit = v;
save();
}
};
}
E.showMenu(menu); E.showMenu(menu);
}) satisfies SettingsFunc }) satisfies SettingsFunc