Avatar for jgw

jgw

Member since May 2021 • Last active Oct 2021
  • 7 conversations
  • 28 comments

Most recent activity

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

    The 'testOut.js' file is sent down using c-code in our devices. These are industrial terminals using an ARM CPU. This download works as it should : connecting, waiting for the prompt then copying 'testOut.js' byte by byte down to Bangle.js 2. Bangle.js 2 responds as it should, so nothing wrong there.

    It is the 'testOut.js' file that is already 'wrong' : the erroneous bytes C3 B9 C3 B0 are the UTF8 representation for 'ùð' : ( https://onlineunicodetools.com/convert-u­nicode-to-utf8 ), and not the original F9 Fo. So using another way for download will not change anything I'm afraid.

    For now, I've changed my code to avoid strings with binary 'characters', using a btoa-version of the binary values. For the example above, this comes down to :

    g.clear().drawImage(atob("DAWBACAHAPnwDg­BA"), 10, 10, {scale:4});
    

    So I'm in the clear for now, but this is a bit of a clumsy workaround of course.

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

    Hello again,
    I ran into another difference while using Web IDE vs Espruino Tools. My programming flow for Bangle.js 2 bracelets involves building a single 'output file' for later download to multiple bracelets. It is mentioned on https://github.com/espruino/EspruinoTool­s that programming is as simple as :

    This file can then be sent directly to Espruino at some later time - sometimes just cat file.js > /dev/ttyACM0 is enough.

    Unfortunately I ran into an issue with 'special character strings'. Consider the following code (this the double arrow image used in Bangle's menu) :

    g.clear().drawImage("\x0c\x05\x81\x00 \x07\x00\xF9\xF0\x0E\x00@", 10, 10, {scale:4});
    

    This is prepared for download with :

    espruino --board BANGLEJS2 --config MINIFICATION_LEVEL=ESPRIMA --config SAVE_ON_SEND=1 /tmp/test.js -o /tmp/testOut.js
    

    'testOut.js' looks like :

    setTime(1634026260.035);E.setTimeZone(-7­)
    require("Storage").write(".bootcde","g.c­lear().drawImage('\\f\\x05\\x81\\0 \\x07\\0ùð\\x0E\\0@',10,10,{scale:4})",0­,67);
    load()
    

    When downloading this to the bracelet, the error 'Too much data for file size' is returned. After some tracing it turns out the download is 69 byte, not 67 (attached image). The image on the bracelet is - obviously - 'mangled'. A dump() looks messed up :

    |  __|___ ___ ___ _ _|_|___ ___
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     2v10.89 (c) 2021 G.Williams
    >
    >
    >dump()
    // Code saved with E.setBootCode
    g.clear().drawImage('\f\x05\x81\0 \x07\0 extends in extends throw\x0E\0@',10,10,{scale:4})=undefined­
    > 
    

    Using the Web IDE and 'Send to Espruino' Flash, the file downloads OK and is 67 byte in size (attached). The dump () :

    >
    >dump()
    // Code saved with E.setBootCode
    g.clear().drawImage('\f\x05\x81\0 \x07\0 ?[249] ?[240]\x0E\0@',10,10,{scale:4})=undefine­d
    > 
    

    The difference are the codes for the 'ùð' characters. The strange thing is that the console dumps in Web IDE (development tools) show the same characters in the 'Sending' prompt, but result in a correct file being stored.

    >>> Sending...
    settingsConsole.js:30 ---> "\u0010reset();\n\u0010print()\n\u0010re­quire(\"Storage\").write(\".bootcde\",\"­g.clear().drawImage('\\\\f\\\\x05\\\\x81­\\\\0 \\\\x07\\\\0ùð\\\\x0E\\\\0@',10,10,{scal­e:4})\",0,67);\n\u0010load()\n\n"
    

    So obviously 'someone' is altering the output of the minified source before sending it down BLE. How then is it possible to just 'cat' an output file to a bracelet ? What are the additional modifications a minified source needs before 'just copying' to a Bangle.js 2 ?

  • in Bangle.js
    Avatar for jgw

    Ah OK. I overlooked the 'lock' event. I does indeed fire after the first tap.
    Thank you

    • 13 comments
    • 569 views
  • in Bangle.js
    Avatar for jgw

    With your suggestions above, I've got a working solution :

    Bangle.setOptions({wakeOnTouch:true});
    
    Bangle.on("touch", function(b, xy) 
    {
      console.log("main - touch",b,xy, Bangle.isLocked());
    });
    
    

    But it looks like, when in locked state, I have to tap twice - not a 'double tap', but tap - wait - tap :

     ____                 _
    |  __|___ ___ ___ _ _|_|___ ___
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     2v10.89 (c) 2021 G.Williams
    >
    >Bangle.isLocked()
    =true
    // Tap
    // No response <============
    // Tap
    // Response
    main - touch 2 { "x": 91, "y": 77, "type": 0 } false
    // Tap
    // Response
    main - touch 1 { "x": 58, "y": 112, "type": 0 } false
    // Tap
    // Response
    main - touch 1 { "x": 62, "y": 110, "type": 0 } false
    //
    // Wait until locked
    //
    // Tap
    // No response <============
    // Tap
    // Response
    main - touch 2 { "x": 90, "y": 76, "type": 0 } false
    // Tap
    // Response
    main - touch 2 { "x": 92, "y": 78, "type": 0 } false
    > 
    

    Or is this normal behavior ?

  • in Bangle.js
    Avatar for jgw

    OK. (Not OK really, because I now have a bunch of watches to update, but at least it's fixed.)

  • in Bangle.js
    Avatar for jgw

    With the above solution I've been using a 'wake on tap' mechanism to get the Bangle.js 2 out of the locked state with a tap on the screen. With 2V09 firmware, this works flawlessly.

    >process.version
    ="2v09.120"
    >Bangle.on("tap",function(t){console.log­("tap",t)})
    =undefined
    > // Tap on a locked Bangle.js 2
    tap {
      "dir": "back",
      "double": false, "x": 0, "y": 0, "z": 1 }
    >
    > 
    

    I now have a Bangle.js 2 with 2V10 firmware. All of the above no longer works. How can I use the 'tap' event in 2V10 ?

    >
    >process.version
    ="2v10.89"
    >Bangle.on("tap",function(t){console.log­("tap",t)})
    =undefined
    > // Some taps here
    >
    
  • in Bangle.js
    Avatar for jgw

    I'm confused. Bangle.js 2 has a '3 bit colour LCD display'.
    With firmware 2V09, this translates nicely to :

    >process.version
    ="2v09.120"
    >g.theme
    ={ fg: 0, bg: 7, fg2: 1, bg2: 3,
      fgH: 0, bgH: 1, dark: false }
    >g.getBPP()
    =3
    > 
    

    But with firmware 2V10, the result confuses me :

    >process.version
    ="2v10.89"
    >g.theme
    ={ fg: 0, bg: 65535, fg2: 31, bg2: 2047,
      fgH: 0, bgH: 2047, dark: false }
    >g.getBPP()
    =16
    > 
    

    Why does it return 16 bits per pixel ? And those 16 bit color values ?

    All of these questions because I have an application running on both 2V09 and 2V10 firmwares and the user can save his preferred colour scheme. The (saved) colour values for 2V09 were 0..7 and now 2V10 apparently expects 0..65535. The saved preferences result in a troubled display, with unreadable menus for changing the user colour, causing a lot of havoc of course.

    (I can't seem to find the 'What's changed' for 2V10 - can someone provide a link - thanks)

Actions