Avatar for Gordon


Member since Sep 2013 • Last active Apr 2017

Most recent activity

  • in Puck.js
    Avatar for Gordon

    Yes, that should be correct - you'll just have to be careful with how you send it to the client, since over Bluetooth LE it could take a while!

    You could also consider just recording it in 8 bits?

  • in Puck.js
    Avatar for Gordon

    Are you using the up to date (1v92) firmware?

    If it still fails I'd try and simplify things a bit... if you have a massive buffer already, why not just write into it directly - for example:

    var clipSeconds = 3;
    var w = new Waveform(512*clipSeconds,{bits:16});
    w.on("finish", function(buf) {
      var a = buf;
      var m=0,n=-1;
      for (var i=150;i<250;i++)if(a[i]>n)n=a[m=i];
      console.log(m.toFixed(0)+"Hz @ "+n);

    It is possible that the buffer size is too large for E.FFT, but there are checks in place to avoid that kind of problem and to throw an error if there isn't enough memory available.

    Failing that, is there a reason you don't want to perform the FFT in smaller chunks and average the result?

  • in Electronics
    Avatar for Gordon

    I haven't heard of anyone doing it directly, but I think it depends on the firmware in the cc2541.

    To get BLE on the Espruino Board you can use an HM-10 module: espruino.com/Bluetooth+BLE

    It's not very well documented, but it does work.

    The HM-10 actually uses the cc2541, so if you could run the HM-10 firmware on your cc2541 then you could communicate with it via serial in the same way.

  • in Puck.js
    Avatar for Gordon

    Take a look at the examples on espruino.com/Reference#l_NRF_­setServices

    When specifying a service, you can add an onWrite handler function which will get called whenever the service is written to (obviously it also has to be set to writable as well)

  • in Puck.js
    Avatar for Gordon

    Great! Thanks for posting up your working code as well!

  • in JavaScript
    Avatar for Gordon

    If you want to reference different intervals at the same time, that can be pretty easy as well:

    var ia = setInterval(...);
    var ib = setInterval(...);
    var ic = setInterval(...);
    // some time later...
    // and later..
    // etc...

    I only suggest the closures because it looked like you wanted to start several copies of the same interval, which would stop themselves

  • in Puck.js
    Avatar for Gordon

    No problem - glad it's sorted! :)

  • in Puck.js
    Avatar for Gordon

    Strange... That all looks good - the services and any stored code should get totally overwritten after doing something like that.

    Are you sure you connected and executed that code on the same Puck.js, and not a different one?

    edit: I literally just tried an update from 1v91 after wiping everything and it seems to work fine. Could you maybe try using a new battery? I guess it's possible that the firmware update itself failed halfway through and that's what is causing the crashes?

  • in JavaScript
    Avatar for Gordon

    The difference is that you are not passing the id in as an argument to setInterval, but are defining it in a function that the callback (the function inside setInterval) has access to.

    In it's simplest form, not this:

    var idAnim;
    function f(){
        idAnim = setInterval(function(id){
        }, 100, idAnim);

    but this:

    function f(){
        var idAnim = setInterval(function(){
        }, 100);

    I'm not quite sure what you're trying to do, but try starting with the code above and then modifying it to do what you want.