-
-
-
-
As you may know, I'm currently developing an "Analog Clock Construction Kit" which (currently) heavily relies on external modules
require
d from GitHub.However, there are modules which behave differently depending on whether they are actually loaded from GitHub (by the Web IDE) or manually inserted into the code using the following "trick"
let exports = {} <<<< insert module here let XXX = exports
as a replacement for
let XXX = require('<GitHub URL>');
Two modules are affected - and I don't know why:
- rounded clock hands - work fine when inserted manually, but produce wrong graphics when loaded from GitHub
- smart clock size calculator - works fine (even if loaded from GitHub), but produces an annoying error toast (
Error: Unreachable point. logically broken. in https://raw.githubusercontent.com/rozek/banglejs-2-smart-clock-size/main/ClockSize.js
) in the WebIDE
Does anybody have any ideas how to solve these problems?
- rounded clock hands - work fine when inserted manually, but produce wrong graphics when loaded from GitHub
-
-
-
-
See GitHub for a very first (and still rough) documentation of this little kit.
I have to stop here for today and hope to fix bugs and brush up the docs tomorrow morning...
-
-
it may be useful to mention in the docs of g.drawPoly and g.fillPoly, that there is a hard-coded limit of the number of polygon nodes - namely 64!
It would have saved me some time I spent developing code which turned out to be principally unable to run because of this restriction!
-
Thank you very much for your comments!
You may already have seen my new "Analog Clock Construction Kit" (elsewhere in this forum) where I try to summarize my findings of the last few days (as the time I may spend to Bangle.js development comes to an end).
This kit allows to plug-in a custom "clockwork" which is also responsible for display updates. The default one shows seconds whenever LCD is "on" and hides them when LCD is off.
This approach may also already solve any visibility problems of the seconds hand.
-
-
I've looked into your code and made a special four-fold clock face for my new Analog Clock Construction Kit (see elsewhere in this forum) which should be compatible with your fonts.
Documentation is still pending, but for the moment:
- set your font once(!) and then
- add
{ Font:'custom', FontScale:1 }
(or a different scaling) to theSettings
- set your font once(!) and then
-
-
I can already offer the following basic modules:
- clockwork:
- simple clockwork with up to 6 complications
- simple clockwork with up to 6 complications
- clock size calculations:
- simple clock size calculation
- smart clock size calculation - should be combined with "Widgets on Background"
- simple clock size calculation
- clock backgrounds:
- bitmap background - should be combined with "Widgets on Background"
- bitmap background - should be combined with "Widgets on Background"
- clock faces:
- clock hands:
- simple clock hands
- rounded clock hands
- hollow hands, optionally filled
- simple clock hands
- complications:
(Most of these modules are already known from my "configurable analog clock")
- clockwork:
-
Since the time I may spend on working with the Bangle.js 2 is running out and there were many good comments on my "configurable analog clock" (see elsewhere in this forum), I've started working on an "Analog Clock Construction Kit".
Basic idea behind this kit is to use a relatively simple code as basis and load the desired clock face, hands and complications from modules stored on GitHub.
Starting simple, I've currently implemented only the most basic variants - but more will follow until this evening. To give you an impression of how to use the kit:
let Clockwork = require('https://raw.githubusercontent.com/rozek/banglejs-2-simple-clockwork/main/Clockwork.js'); let ComplicationPlaceholder = require('https://raw.githubusercontent.com/rozek/banglejs-2-complication-placeholder/main/Complication.js'); Clockwork.windUp({ size: require('https://raw.githubusercontent.com/rozek/banglejs-2-simple-clock-size/main/ClockSize.js'), background:null, face: require('https://raw.githubusercontent.com/rozek/banglejs-2-four-fold-clock-face/main/ClockFace.js'), hands: require('https://raw.githubusercontent.com/rozek/banglejs-2-simple-clock-hands/main/ClockHands.js'), complications:{ tl:null, t:ComplicationPlaceholder, tr:null, l:ComplicationPlaceholder, r:ComplicationPlaceholder, bl:ComplicationPlaceholder, b:null, br:ComplicationPlaceholder } },{ Foreground:'#FFFFFF', Background:'#000000', Seconds:'#FFFF00' });
As you can see, "implementing" an analog clock is essentially reduced to loading the desired clockwork, background, face, hands and complications (the latter have to be loaded into their placement "slots") and, perhaps, providing some configuration details.
See GitHub for a very first (and still rough) documentation of this little kit.
-
-
I'm currently working on an "Analog Clock Construction Kit" using modules which are stored on GitHub.
But it seems, that
require('...')
not always loads the latest version of these modules, but seems to cache them internally (if I enter the module's raw URL into the browser, I indeed get the latest version).How can I convince the Web IDE to drop the cached version of a module and prefer the new one?
-
Thank you very much for your quick response!
Documentation wants me to write a module to storage in the following way:
require('Storage').write('SmokeTest',` exports.getAnswer = function () { return 42; } `);
i.e., obviously un-minified and not pre-tokenized.
Could I use the following approach instead?
let exports = {}; exports.getAnswer = function () { for (let i = 0, j = 0; i < 1000; i++) { j++; // just consume some time... } return 42; }; let ModuleSource = ''; for (let Key in exports) { if (exports.hasOwnProperty(Key)) { ModuleSource += 'exports.' + Key + '=' + exports[Key] + ';'; } } require('Storage').write('SmokeTest',ModuleSource);
If I just
print
the contents ofModuleSource
, I getexports.getAnswer=function () {for(let i=0,j=0;i<1000;i++){j++;}return 42;}
which looks quite promising (in terms of minification, at least)...
-
I'm currently experimenting with Espruino modules (on a Bangle.js 2).
From the documentation it looks as if modules are written to Flash as source code - non-minified, not pre-tokenized. This sounds as if modules will have to be parsed (and perhaps tokenized) when "require"d for the first time.
Does that mean that modules consume RAM while other code may be run from Flash?
(by the way: is it intended that module file names do not end with a ".js" suffix? Would those three characters also count as the eight which are allowed?
Amendment: a (probably important) detail of my intention is: I want to load modules at run-time(!) and not as part of the right-hand side of the Web IDE! The idea is to load modules as required by a configuration file
-
-
-
-
If you like, you may try my new Analog Clock Construction Kit. Using that kit would reduce your implementation effort to just writing code for drawing the desired clock face.