bangle js bangle js
play

BANGLE.JS BANGLE.JS CREATING A SMART WATCH WITH JAVASCRIPT - PowerPoint PPT Presentation

BANGLE.JS BANGLE.JS CREATING A SMART WATCH WITH JAVASCRIPT CREATING A SMART WATCH WITH JAVASCRIPT Gordon Williams, @Espruino https://youtu.be/BjgFC0M3iMk NRF52832 NRF52832 Bluetooth LE on-chip ARM Cortex M4 @ 64 MHz 64kB RAM, 512kB Flash


  1. BANGLE.JS BANGLE.JS CREATING A SMART WATCH WITH JAVASCRIPT CREATING A SMART WATCH WITH JAVASCRIPT Gordon Williams, @Espruino

  2. https://youtu.be/BjgFC0M3iMk

  3. NRF52832 NRF52832 Bluetooth LE on-chip ARM Cortex M4 @ 64 MHz 64kB RAM, 512kB Flash (reprogrammable)

  4. SPECS SPECS nRF52 ARM Cortex-M4 with Bluetooth LE 240x240x16 bit touchscreen LCD GPS (GPS, Glonass, Beidou) 3 Axis Compass 3 Axis Accelerometer 4MB flash Heart Rate Monitor

  5. $ unzip -l F7_dfu_g095cb_C07_v1.66.15.zip | grep hex 47436 1980-00-00 00:00 res/raw/ble_app_hrs_dfu_s110_v7_1_0.hex 54064 1980-00-00 00:00 res/raw/ble_app_hrs_s110_v6_0_0.hex 60460 1980-00-00 00:00 res/raw/ble_app_hrs_s110_v7_0_0.hex 52620 1980-00-00 00:00 res/raw/ble_app_rscs_s110_v6_0_0.hex 59052 1980-00-00 00:00 res/raw/ble_app_rscs_s110_v7_0_0.hex 2600 1980-00-00 00:00 res/raw/blinky_arm_s110_v7_0_0.hex 1916 1980-00-00 00:00 res/raw/blinky_s110_v7_1_0.hex

  6. 0000000 fa58 2000 c5b1 0001 c5b9 0001 c5bb 0001 0000010 c5bd 0001 c5bf 0001 c5c1 0001 0000 0000 0000020 0000 0000 0000 0000 0000 0000 c5c3 0001 0000030 c5c5 0001 0000 0000 c5c7 0001 c5c9 0001 0000040 c5cb 0001 c5cb 0001 0995 0002 0271 0002 0000050 02a1 0002 c5cb 0001 f881 0001 00a5 0002 0000060 05f5 0002 0609 0002 c5cb 0001 c5cb 0001 0000070 c5cb 0001 c5cb 0001 c5cb 0001 c5cb 0001 0000080 0a89 0002 008d 0002 c5cb 0001 c5cb 0001 0000090 02c9 0002 c5cb 0001 02cd 0002 c5cb 0001 00000a0 c5cb 0001 c5cb 0001 c5cb 0001 c5cb 0001 00000b0 c5cb 0001 c5cb 0001 0000 0000 0000 0000 00000c0 c5cb 0001 c5cb 0001 c5cb 0001 c5cb 0001 00000d0 c5cb 0001 c5cb 0001 c5cb 0001 0000 0000

  7. 0000000 fa58 2000 c5b1 0001 c5b9 0001 c5bb 0001 0x2000fa58 -> Initial stack pointer 0x0001c5b1 -> Reset vector (entrypoint) 0x0001c5b9 -> NMI 0x0001c5bb -> Hardfault handler ...

  8. CHROME LITE MODE CHROME LITE MODE

  9. OTHER ENGINES OTHER ENGINES V7 Duktape JerryScript ...

  10. ESPRUINO ESPRUINO JS interpreter for Microcontollers Open Soure MPLv2 Can run in 128kB Flash under 6kB RAM Not 100% ES5, but RegEx, Classes, Promises, Arrow fns, Template Literals http://www.espruino.com/Features

  11. Typical PC Typical BLE Microcontroller CPU 3GHz x2 64MHz x1 RAM 8 GB 64 kB ROM 256 GB 512 kB Bytes / MHz 44 0.01

  12. MEMORY FRAGMENTATION MEMORY FRAGMENTATION A is allocated |AAAA | Allocate BCDEFG... |AAAABCDEFGHIJLKMNOPQRSTUVWXYZ | De-allocate odd items |AAAA C E G I L M O Q S U W Y | 15 memory elements free, but max we can allocate is 3!

  13. FIXED SIZE VARIABLES FIXED SIZE VARIABLES Offset Name STRING STR_EXT NAME_STR NAME_INT INT DOUBLE OBJ/FUNC/ARRAY ARRAYBUFFER 0 - 3 varData data data data data data data nativePtr size 4 - 5 next data data next next - data argTypes format 6 - 7 prev data data prev prev - data argTypes format 8 - 9 first data data child child - - first stringPtr 10-11 refs refs data refs refs refs refs refs refs 12-13 last nextPtr nextPtr nextPtr - - - last - 14-15 Flags Flags Flags Flags Flags Flags Flags Flags Flags

  14. CODE SIZE CODE SIZE Based on code to create a Mandelbrot fractal: Format Size (Bytes) Normal JS 300 Minified JS 167 Minified Tokenised JS 155 Spidermonkey Bytecode 270 290 GCC -Os

  15. 64 blocks, 11 bytes/block => 700 bytes

  16. WEB BLUETOOTH WEB BLUETOOTH Access Bluetooth LE from a Web Page Chrome/Opera/Edge Windows 10, Mac OS, Chromebook, Android, Linux, Pi WebBLE app for iOS Packages for Web Bluetooth on Node.js Espruino for Microcontrollers

  17. Tools

  18. App Store

  19. Speedometer Bangle.setGPSPower(1); Bangle.setLCDMode("doublebuffered"); var lastFix = {fix:0,satellites:0}; function onGPS(fix) { lastFix = fix; g.clear(); g.setFontAlign(0,0); g.setFont("6x8"); g.drawString(fix.satellites+" satellites",120,6); if (fix.fix) { var txt = (fix.speed<20) ? fix.speed.toFixed(1) : Math.round(fix.speed); var s = 80; g.setFontVector(s); g.drawString(txt,120,80); g.setFont("6x8",2); g.drawString("km/h",120,80+16+s/2); } else { g.setFont("6x8",2); g.drawString("Waiting for GPS",120,80); } g.flip(); } onGPS(lastFix); Bangle.on('GPS', onGPS);

  20. Emulation

  21. BANGLE.JS BANGLE.JS Currently on pre-order, shipping end of March.

  22. BANGLEJS.COM BANGLEJS.COM ESPRUINO.COM ESPRUINO.COM @ESPRUINO @ESPRUINO banglejs.com

More recommend