Avatar for Coder2012


Member since Jan 2015 • Last active Oct 2018
  • 5 conversations

Most recent activity

  • in JavaScript
    Avatar for Coder2012

    It would be help full to explain what you want to achieve from a birds point of view.

    So when I first got the original Espruino I created animations for my LED lights using setInterval functions.

    The code quickly became verbose as I added more patterns. I experimented back then trying to use gsap but there wasn't enough memory.

    When I decided to look again and was amazed that the Espruino WiFi version was out with more memory I thought my idea could work out.

    Gsap is designed for the browser as it transitions elements in the DOM but can also transition values on objects you create yourself, therefore you're not restricted to just DOM objects or the window object in the browser.

    I've since looked at smaller libraries that could work as I want to interpolate between values to use on these lights, the power of a tween library is that it has various helper functions like repeat, reverse and yo-yo to aid with creativity.

  • in JavaScript
    Avatar for Coder2012

    Ah so originally when I wanted to use the 'gsap' module, I thought I'd install it in the modules folder that was created by the sandbox project thingy. To do this all you need to do (as long as you have nodejs installed of course) is:

    npm install gsap

    This creates the 'node_modules' folder with another folder called gsap inside, inside this is all the files associated with the gsap module.

    Then in node at least, you just require it and off you go...

    What I hadn't realised (but do now after reading the forums) is that there was a beta NPM setup but that was dropped, possibly unrelated to my issue anyway (I'm digressing here) but I thought maybe the Espruino expected local modules to reside in a 'node_modules' folder, but it doesn't.

    Hope that clears up any confusion I've caused?

  • in JavaScript
    Avatar for Coder2012

    I just renamed the 'TweenLite.min.js' to 'gsap' so I could do:

    var gsap = require('gsap');

    Didn't use node_modules anywhere. It works fine regardless of where my sandbox folder is in the two cases mentioned previously.

    I think you're right about not being able to use this on Espruino though as I can't seem to call any functions on it.

    I was hoping to use it with the WS2811 lights, I used to do all my anims manually with setInterval but I've extensive knowledge of this library from doing frontend dev over the years and had an idea to Tween values using this as it's so powerful, maybe it will work out or maybe it won't...

    PS. It can be used on nodejs so maybe there's a way to get it to play with Espruino.

  • in JavaScript
    Avatar for Coder2012

    OK so this is now working, thank you for pointing me in the right direction with the question if I had written this module myself!!!

    I created a quick module to check and that was indeed loaded correctly, which made me think ahhhh I need to rename the downloaded module so that the filename matches what the Espruino is looking for, this isn't necessary using node_modules as it uses the folder name as the mapping I believe.

    So it is now loading the module as expected.. Sorry for the confusion and thanks for the support.

  • in JavaScript
    Avatar for Coder2012

    Just to confirm, module 'gsap' is one you created? (as it isn't present at)

    No I want to use gsap from here, well specifically i will want TweenLite as I may run into memory problems as gsap could be too big I think.


    I tried a new folder at the C root, still no joy, it appears to me that it doesn't even attempt to look in the modules folder at all according to the console output...

  • in JavaScript
    Avatar for Coder2012

    Hi Robin,

    Thanks for the reply, here's my answers to your questions...

    What PC and OS is the IDE running on? -Desktop AMD 1700x custom built - Windows 10 professional

    What is the version of IDE? native or Chrome? Settings >> About -Web IDE version 0.70.4 chrome app.

    Version of Espruino? process.env - VERSION": "1v99",
    "GIT_COMMIT": "f0d66ba",
    "FLASH": 524288, "RAM": 131072,
    "SERIAL": "29004900-0c513532-39333638",
    "CONSOLE": "USB",
    "MODULES": "Flash,Storage,fs," ... ",neopixel,Wifi,AT",
    "EXPTR": 536871156

    Are you using an SD card? No sir

    File Path to the sandbox folder? Settings >> Project - C:\git\espruino\leds

    Here's the console messages:

    Firmware >1.43 supports faster writes over USB
    Set Slow Write = false
    FIRMWARE: Current 1v99, Available 1v99
    Device found {"bitrate":9600,"bufferSize":4096,"conne­ctionId":12,"ctsFlowControl":false,"data­Bits":"eight","name":"","parityBit":"no"­,"paused":false,"persistent":false,"rece­iveTimeout":0,"sendTimeout":0,"stopBits"­:"one"}
    [success] Connected to COM7

    Connected to COM7
    ERROR: getURL("https://www.espruino.com/modules/gsap.mi­n.js") error : Not Found
    ERROR: getURL("https://www.espruino.com/modules/gsap.js­") error : Not Found
    WARNING: [notify_warn] Module gsap not found
    Received a prompt after sending newline... good!
    Splitting for reset(), delay 250

  • in JavaScript
    Avatar for Coder2012

    I have tried a few ways to put a module in my local project. In the web ide I have set a folder for a project, this created a bunch of folders, one of them modules - I have tried to NPM install a module gsap there but I cannot require this with:

    var gsap = require('gsap');

    I thought maybe it doesn't need to be in node_modules folder so I took out the gsap folder and only that is in modules, still can't find it.

    I copied the min.js file to modules folder, still cannot require it there.

    Both of these examples work if I use the cmd to run node and the require('gsap'). What is the correct way to require a module from modules folder in a project?

  • in General
    Avatar for Coder2012

    Oh wow, these look like great ways to make prototyping simple. Thanks DrAzzy.