lsm9ds1 #899
Replies: 5 comments
-
Posted at 2016-11-19 by luwar
There are no special minification settings required. Your module will be minified during the build of the website with the Google Closure Compiler, more precisly the Closure Compiler Service API in optimization level 'SIMPLE_OPTIMIZATIONS'. The minifier knows among other things that If you want further minification (about 1/3 smaller) then you could use ADVANCED_MINIFACTION. You have to create an *.externs file which references your public module API. This is an easy task, but additional testing of the minified module is required! For the ADS1X15 it would look like: ADS1X15.externs:
The BME280 is a module which uses advance minification: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-11-20 by ClearMemory041063 Thanks @luwar.
I invoke this experimental module using the following:
The output with No Module minification
Module minification Esprima (offline)
Module minification Closure (online) –Whitespace only
Module minification Closure (online) – Simple optimizations
Module minification Closure (online) – Advanced
From the Usage values the Advanced option seems to do the best job.. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-11-20 by luwar I don't know the current state of the WebIDE but a few weeks ago the "Advanced" option did not work in general. The reason is that calls to the Espruino API will be minified/renamed too. http://forum.espruino.com/conversations/292590/#comment13205984 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-11-20 by @allObjects @luwar, https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler may be the solution here... Encapsulation is handled better or worse in other languages... better means: more obvious and and enforced, where as JavaScript gives a lot of freedom and therefore expects more from the discipline of the coder... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-11-21 by @gfwilliams Yes, advanced optimisation works in small cases, but tends to optimise out a lot of Espruino functions which causes problems for anything sensibly sized. I'd definitely recommend just simple optimisations. These work pretty well and don't require you to do anything special to your code. The main things are:
Also: I think that if you look in the console (via settings) you might be able to see what the code has minified down to - which could be some help? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-11-19 by ClearMemory041063
I’m starting work on an I2C driver for the Sparkfun 9DoF Sensor Stick
https://www.sparkfun.com/products/13944
3-axis Magnetometer, Gyro and Accelerometer.
As a starting point I’ve downloaded the Arduino Library from
https://github.com/sparkfun/SparkFun_LSM9DS1_Arduino_Library
I’ve edited the LSM9DS1_register.h header file changing the #define to a variable object.
I looked at some existing modules and found an interesting comment in this one.
https://www.espruino.com/modules/ADS1X15.js
The comment:
What minification settings are used to make this trick work?
Beta Was this translation helpful? Give feedback.
All reactions