Espruino 1v93 released

Posted on
  • This one's been a while coming, but there are some great new additions:

    The biggest one is E.setFlags({pretokenise:1})

    This puts the JS interpreter into a mode where any function that's defined is tokenised as it is stored. All reserved words are squashed down to a single byte, and all whitespace is removed. It seems to give a 10-20% speedup of execution, but crucially it hugely reduces the memory usage.

    So if you're having problems with memory usage, type E.setFlags({pretokenise:1}) on the left-hand side of the IDE, then re-upload and see what happens.

    There's also:

    • NetworkJS error reporting - errors reported by ESP8266/GSM connections can now be handled nicely with connection.on('error'...)
    • Autocompleted pin names - it's small, but really useful if you're typing on the left-hand side of the IDE and hit Tab to autocomplete the available pins
    • Puck.js - you can now call BluetoothRemoteGATTServer.startBonding to initiate bonding with Puck.js as the central device, which can include a secure connection
    • Hardware 'clear to send' flow control on any Serial device - this can be really useful when Espruino is receiving high speed serial data from devices (for example ESP8266) and the input buffer could get full up
    • Array.indexOf finally gets fromIndex support
    • Puck.js random numbers are now seeded from the hardware random number generator on boot
    • Date setters and timezone support with E.setTimeZone. You can now finally get the correct time based on your country's timezone, without having to manually tweak the date.
    • Serial error handling is now disabled by default and enabled via an option in Serial.setup. Previously framing/parity errors were added to the input queue regardless, and could fill it up quickly in the case of invalid serial data.
    • Puck.js services and advertising are now re-initialised after save() - and are also dumped to the console using dump()
    • Puck.js: Added NRF.getAdvertisingData as well as the ability to supply an array of objects to NRF.setAdvertising to allow for some pretty advanced use of advertising
    • Puck.js: Added BluetoothRemoteGATTServer.getSecuritySta¬≠tus to allow the security status of a Bluetooth central link to be checked
    • Puck.js: Auto-whitelisting now disabled by default (fixes connection problems with other devices after bonding)
    • atob and btoa now use flat strings for their output if possible, so are way more memory efficient than before.
    • Puck.js: Added Puck.magTemp() function to get the magnetometer's temperature as well as the BLE module's
    • Added E.set/getFlags to allow interpreter state to be set and queried from one place

    There are a whole bunch of fixes too - check them out here:

    A few of the main ones are:

    • A whole selection of Puck.js stability/reliability tweaks
    • Fix the multiple end/close callbacks that happened on TCP/IP sockets
    • NFC fixes on Puck.js (after using NFC, Puck.js could get stuck in a high power mode)
    • Puck.js neopixel library now colors the first LED correctly
    • Floating point numbers are now never output with a trailing . - which could break some parsers
    • Added regex parsing (not actual regex support, but now you'll get a helpful error)
    • Fix dumping of ArrayBuffers containing data - it now produced valid executable JS
  • Is E.setFlags({pretokenise:1}) compatible with Modules uploaded as functions?
    Could combing the two add any adventage?

  • It is, but it depends how you use it...

    pretokenise + modules as functions will still work, but won't realistically be any better than just pretokenise.

    Save on send + modules as functions will load your code into flash memory, so in that case the functions won't be tokenised at all since they're read only - so you won't see any difference.

  • looks great!

  • Nice updates.
    One question about bonding: Is it necessary that the Puck establishes the connection to a device or is it also possible to listen for a connection establishment by a smartphone and then start the bonding?

  • If some other device is connecting to Puck.js, then that device can request bonding and Puck.js will bond - however as far as I know if it up to the connecting device to initiate the bonding.

  • Is there ever any reason not to pretokenize?

  • If you wanted to be able to dump() the code that you'd uploaded (or edit functions in-place with edit) then it'd be a pain as it would remove all formatting and effectively output 'minified' code for you, but yes, in a lot of cases you could leave it on.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Espruino 1v93 released

Posted by Avatar for Gordon @Gordon