-
• #2
One problem is you can't go back from the app settings to the settings menu.
You could maybe put the drawing code in a separate library file, like e.g. the weather app does, so you'd have something like this:
// apps/contourclock/lib.js exports.drawClock = function(time, face) { // draw clockface [#face](https://forum.espruino.com/search/?q=%23face), at given time } // apps/contourclock/app.js var face = Storage.readJSON('contourclock.json').face setInterval(()=>require('contourclock').drawClock(new Date(), face), 60000); // apps/contourclock/settings.js (function(back) { function preview(face) { require('contourclockclock').drawClock(new Date(), face); } // settings menu using preview() goes here }) // apps.json { "id": "contourclock" "storage": [ {"name":"contourclock.app.js","url":"app.js"}, {"name":"contourclock","url":"lib.js"}, {"name":"contourclock.settings.js","url":"settings.js"} ], }
-
• #3
Thanks a lot! One more problem: The drawClock function needs a font module. if i put
require("FontTeletext10x18Ascii").add(Graphics);
in the main clock code, the font is loaded and works in drawClock. The same code does not work in the settings app, i get
Contour Clock settings error: Error: Error: Module FontTeletext10x18Ascii not found
Loading the font in the library does not work either, but does not produce an error message...
I had some problem creating a settings menu for my clock. I wanted to preview different clock faces, for which i would need some functions from the clock app. Apparently, it is impossible to import functions into the settings app. My workaround was to just write a very basic settings.js:
The clock app just has to check for "settings.editMode", disable UI and enter its own settings mode.
Are there any problems with this approach?