Avatar for jgw

jgw

Member since May 2021 • Last active Sep 2021
  • 6 conversations
  • 21 comments

Most recent activity

  • in Puck.js, Pixl.js and MDBT42
    Avatar for jgw

    Yes, now it works ! The resulting number of bytes from the message 'No errors. Minified xxx bytes to yyy bytes.' is identical in both cases, so chances are both builds come up with the exact same result.

    As it happens, in this case the esmangle development has been really flaky

    I also struggle with the 'wonderful world' of open source modules. One can usually only guess at things like quality and longevity, but hey, apart from time spent, it's free....

    In the open source world, the Espruino project is a notable exception in terms of quality and support.

    Thank you again for the quick response.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for jgw

    That already is better, but...
    Another error is presented (which I do not have in Web IDE). I can reproduce it with the following :

    var dummy = 123;
    console.log(`dummy = ${dummy}`);
    var mod = require("esprimaMod");
    

    with 'esprimaMod.js' as :

    function something()
    {
    }
    
    exports.connect = function ()
    {
    	return something;
    };
    

    and the resulting error at line 29 and 42:

    root@ubuntu:~# espruino --verbose --board BANGLEJS2 --config MINIFICATION_LEVEL=ESPRIMA --config MODULE_MINIFICATION_LEVEL=ESPRIMA --config PRETOKENISE=true --config SAVE_ON_SEND=1 --config MODULE_EXTENSIONS=.js --config  MODULE_URL=SmartBracelet/software/module­s --minify SmartBracelet/software/projects/esprima.­js -o SmartBracelet/software/es.js
    0.1.39
    Espruino Command-line Tool 0.1.39
    -----------------------------------
    
    Acorn library not found - you''ll need it for compiled code
    Found /usr/local/lib/node_modules/espruino/lib­s/targz.js
    ...
    Initialising CoreModules
    Command-line option set Espruino.Config.MINIFICATION_LEVEL to "ESPRIMA"
    Command-line option set Espruino.Config.MODULE_MINIFICATION_LEVE­L to "ESPRIMA"
    Command-line option set Espruino.Config.PRETOKENISE to true
    Command-line option set Espruino.Config.SAVE_ON_SEND to 1
    Command-line option set Espruino.Config.MODULE_EXTENSIONS to ".js"
    Command-line option set Espruino.Config.MODULE_URL to "SmartBracelet/software/modules"
    Explicit board JSON supplied: "BANGLEJS2"
    Loading http://www.espruino.com/json/BANGLEJS2.j­son
    Board JSON loaded
    Manual board JSON load complete
    No port supplied, but output file listed - not connecting
    Loading modules
    loadModule(esprimaMod)
     - esprimaMod requires []
    Minifyingn esprimaMod
    No errors in esprimaMod. Minified 81 bytes to 66 bytes.
    Minification complete
    Since Acorn 8.0.0, options.ecmaVersion is required.
    Defaulting to 2020, but this will stop working in the future.
    { SyntaxError: Unexpected token (1:54)
        at Parser.pp$5.raise (/usr/local/lib/node_modules/espruino/no­de_modules/acorn/dist/acorn.js:3416:15)
        at Parser.pp.unexpected (/usr/local/lib/node_modules/espruino/no­de_modules/acorn/dist/acorn.js:741:10)
        at Parser.pp.semicolon (/usr/local/lib/node_modules/espruino/no­de_modules/acorn/dist/acorn.js:718:66)
        at Parser.pp$1.parseExpressionStatement (/usr/local/lib/node_modules/espruino/no­de_modules/acorn/dist/acorn.js:1201:10)
        at Parser.pp$1.parseStatement (/usr/local/lib/node_modules/espruino/no­de_modules/acorn/dist/acorn.js:934:26)
        at Parser.pp$1.parseBlock (/usr/local/lib/node_modules/espruino/no­de_modules/acorn/dist/acorn.js:1217:23)
        at Parser.pp$4.parseFunctionBody (/usr/local/lib/node_modules/espruino/no­de_modules/acorn/dist/acorn.js:3242:24)
        at Parser.pp$1.parseFunction (/usr/local/lib/node_modules/espruino/no­de_modules/acorn/dist/acorn.js:1339:10)
        at Parser.pp$4.parseExprAtom (/usr/local/lib/node_modules/espruino/no­de_modules/acorn/dist/acorn.js:2772:19)
        at Parser.pp$4.parseExprSubscripts (/usr/local/lib/node_modules/espruino/no­de_modules/acorn/dist/acorn.js:2583:21) pos: 54, loc: Position { line: 1, column: 54 }, raisedAt: 55 }
    Error parsing JavaScript, but uploading anyway.<br/>SyntaxError: Unexpected token (1:54)
    Minifying
    Error: Line 1: Unexpected token {
    Error: Line 1: Unexpected token {
        at ErrorHandler.constructError (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:5012:22)
        at ErrorHandler.createError (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:5028:27)
        at Parser.unexpectedTokenError (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:1985:39)
        at Parser.throwUnexpectedToken (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:1995:21)
        at Parser.consumeSemicolon (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:2297:23)
        at Parser.parseLabelledStatement (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:4029:19)
        at Parser.parseStatement (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:4122:97)
        at Parser.parseStatementListItem (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:3393:31)
        at Parser.parseFunctionSourceElements (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:4195:29)
        at Parser.parseFunctionExpression (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:4408:26)
    Minification complete
    (node:69905) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected character '«' (1:76)
        at Parser.pp$5.raise (/usr/local/lib/node_modules/espruino/no­de_modules/acorn/dist/acorn.js:3416:15)
        at Parser.pp$9.getTokenFromCode (/usr/local/lib/node_modules/espruino/no­de_modules/acorn/dist/acorn.js:5081:10)
        at Parser.pp$9.readToken (/usr/local/lib/node_modules/espruino/no­de_modules/acorn/dist/acorn.js:4765:17)
        at Parser.pp$9.nextToken (/usr/local/lib/node_modules/espruino/no­de_modules/acorn/dist/acorn.js:4756:17)
        at Parser.pp$9.next (/usr/local/lib/node_modules/espruino/no­de_modules/acorn/dist/acorn.js:4717:10)
        at Parser.pp$9.getToken (/usr/local/lib/node_modules/espruino/no­de_modules/acorn/dist/acorn.js:4721:10)
        at Object.next (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:115:20)
        at pretokenise (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:164:17)
        at Array.eval (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:31:7)
        at cb (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:98:15)
    (node:69905) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
    (node:69905) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    

    No idea where that 'unexpected token {' would be at in above simple code...

    I honestly thought Espruino Tools used the very same chain of tools as Web IDE does, but apparently this is not the case ? I'm trying to use the tools for distributing an app to multiple Bangle.js 2's, but if Espruino Tools builds 'something different' as compared to Web IDE (where the app was fully debugged), I do not feel particularly comfortable...

  • in Puck.js, Pixl.js and MDBT42
    Avatar for jgw

    Hi,
    I'm building a 'command-line-script' to download an application to multiple Bangle.js 2 devices using Espruino Tools on Linux. I ran into a strange problem.

    Consider this (isolated) piece of code :

    var dummy = 123;
    
    console.log(`dummy = ${dummy}`);
    
    

    When minifying this is the Web IDE, no problems (of course...).

    When running minification with the Espruino Tools, a strange error is reported (line 62 below):

    root@ubuntu:~# espruino --verbose --board BANGLEJS2 --config MINIFICATION_LEVEL=ESPRIMA --config MODULE_MINIFICATION_LEVEL=ESPRIMA --config PRETOKENISE=true --config SAVE_ON_SEND=1 --minify SmartBracelet/software/projects/esprima.­js -o SmartBracelet/software/es.js
    0.1.38
    Espruino Command-line Tool 0.1.38
    -----------------------------------
    
    Acorn library not found - you''ll need it for compiled code
    Found /usr/local/lib/node_modules/espruino/lib­s/targz.js
    ...
    Found /usr/local/lib/node_modules/espruino/cor­e/serial_winnus.js
    Not on Windows, Winnus not needed
    Found /usr/local/lib/node_modules/espruino/cor­e/terminal.js
    Found /usr/local/lib/node_modules/espruino/cor­e/utils.js
    Found /usr/local/lib/node_modules/espruino/plu­gins/assembler.js
    Found /usr/local/lib/node_modules/espruino/plu­gins/boardJSON.js
    Found /usr/local/lib/node_modules/espruino/plu­gins/compiler.js
    Found /usr/local/lib/node_modules/espruino/plu­gins/getGitHub.js
    Found /usr/local/lib/node_modules/espruino/plu­gins/localModules.js
    Found /usr/local/lib/node_modules/espruino/plu­gins/minify.js
    Found /usr/local/lib/node_modules/espruino/plu­gins/pretokenise.js
    Found /usr/local/lib/node_modules/espruino/plu­gins/saveOnSend.js
    Found /usr/local/lib/node_modules/espruino/plu­gins/setTime.js
    Found /usr/local/lib/node_modules/espruino/plu­gins/unicode.js
    UTF8 Library loaded successfully
    Found /usr/local/lib/node_modules/espruino/plu­gins/versionChecker.js
    Initialising CodeWriter
    Initialising Config
    Initialising Env
    Initialising Flasher
    Initialising FlasherESP8266
    Initialising Modules
    Initialising Notifications
    Initialising Serial
      - Initialising Serial Noble Bluetooth LE
      - Initialising Serial Node Socket
      - Initialising Serial Web Audio
      - Initialising Serial Web Bluetooth
      - Initialising Serial Web Serial
    Initialising Utils
    Initialising Status
    Initialising Assembler
    Initialising BoardJSON
    Initialising Compiler
    Initialising GetGitHub
    Initialising LocalModules
    Initialising Minify
    Initialising Pretokenise
    Initialising SaveOnSend
    Initialising SetTime
    Initialising Unicode
    Initialising VersionChecker
    Initialising CoreModules
    Command-line option set Espruino.Config.MINIFICATION_LEVEL to "ESPRIMA"
    Command-line option set Espruino.Config.MODULE_MINIFICATION_LEVE­L to "ESPRIMA"
    Command-line option set Espruino.Config.PRETOKENISE to true
    Command-line option set Espruino.Config.SAVE_ON_SEND to 1
    Explicit board JSON supplied: "BANGLEJS2"
    Loading http://www.espruino.com/json/BANGLEJS2.j­son
    Board JSON loaded
    Manual board JSON load complete
    No port supplied, but output file listed - not connecting
    Minifying
    TypeError: Cannot read property 'length' of undefined
    TypeError: Cannot read property 'length' of undefined
        at Controller.traverse (/usr/local/lib/node_modules/espruino/no­de_modules/esmangle/node_modules/estrave­rse/estraverse.js:411:38)
        at Object.traverse (/usr/local/lib/node_modules/espruino/no­de_modules/esmangle/node_modules/estrave­rse/estraverse.js:556:27)
        at annotateDirective (/usr/local/lib/node_modules/espruino/no­de_modules/esmangle/lib/annotate-directi­ve.js:131:16)
        at Object.optimize (/usr/local/lib/node_modules/espruino/no­de_modules/esmangle/lib/esmangle.js:159:­16)
        at obfuscate (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:117:23)
        at minifyCodeEsprima (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:98:18)
        at minify (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:212:23)
        at Array.eval (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:60:7)
        at cb (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:98:15)
        at compileCode (eval at loadJS (/usr/local/lib/node_modules/espruino/in­dex.js:12:11), <anonymous>:154:7)
    Minification complete
    Since Acorn 8.0.0, options.ecmaVersion is required.
    Defaulting to 2020, but this will stop working in the future.
    Uploading 45 bytes to flash
    Writing output to SmartBracelet/software/es.js
    Done
    

    Platform is Ubuntu 18.04, Node version is V8.10.0, espruino (tools) is V0.1.38.

  • in Bangle.js
    Avatar for jgw

    Yes, that works ! Thank you.

  • in Bangle.js
    Avatar for jgw

    A use case for a Bangle.js 2 device requires me to replace the complete set of 'Default Applicactions' that normally live on the device.

    I've accomplished that with

    require("Storage").eraseAll()
    

    followed with a 'Send to Espruino Flash'. This has all been successful and my application is running fine.
    One question I have is how to prevent console messages and system errors from appearing on the Bangle.js 2 display.

    I've studied the default 'settings.js' app that toggles the 'log' attribute in 'setting.json' but makes no application call to inform Espruino.

    I've written a 'setting.json' file to Flash with 'log' set to false, but messages keep displaying (in a very small font where I can only make out the word 'Bluetooth' every time a BLE message is received).

    I have not experimented with E.setConsole() since I did not want to lose my console the next time I connect with the IDE - or is this of no concern ?

    So, how does one disable debug messages from appearing on a Bangle.js 2 ?

  • started
    • 6 comments
    • 309 views
  • in Bangle.js
    Avatar for jgw

    Indeed, adding characters to the SVG font looks like too much work (too bad, the vector font really looks great).
    So, generating bitmap fonts to fit my needs seems the way to go. A first experiment with http://www.espruino.com/Font+Converter returns a usable font which displays OK on the Bangle.js 2, but 'cuts' characters gjpq... at the bottom. I've tried several heights, but same result.

    Webfont is

    link href="https://fonts.googleapis.com/css2?family­=Roboto&wght@400&display=swap" rel="stylesheet"

    Resulting font is attached.

    Any ideas ?

  • in Bangle.js
    Avatar for jgw

    Yes I already discovered that, but true internationalization requires more variants of ISO8859 https://en.wikipedia.org/wiki/Windows_co­de_page#Windows-125x_series .

    Do you know of a tool that converts a vector font to the tables in 'libs/graphics/vector_font.c') ? Or were these generated 'by hand' ? That way one could easily include additional char128-255-tables to mimic the idea of 'code page switching' Windows used to implement.

Actions