Avatar for gomako

gomako

Member since Apr 2015 • Last active Apr 2017
  • 5 conversations
  • 32 comments

Most recent activity

  • started
    • 34 comments
    • 1,142 views
  • in Puck.js
    Avatar for gomako

    @tc I'm glad it came in useful. I don't think it's super accurate but if it gets the job done then that's ok!

  • in Puck.js
    Avatar for gomako

    I have just updated a thread where I was asking the same question http://forum.espruino.com/comments/13395­796/

    That will show you how to get the approximate readings (0 is North, -90 is West, 90 is East and 180 is South), so you will be able to use them in the rest of your code. I'd be interested to see it posted, good luck!

  • in Puck.js
    Avatar for gomako

    Digging up an old thread here, but I kind of got it working enough for what I want.

    I did what was suggested an took four readings at N,S,E,W, averaged them and deducted them from what Puck.mag() gave me back, then I ran it through the function I had before and it gave me accurate enough readings for the headings (0 for North, 180 for South, -90 for West and 90 for East). They aren't super accurate, but I'm guessing that's because of the nearby magnetic fields etc.

    My code is below:

    // Be sure to take your own readings for your own magnetic environment!
    const avg = { "x": -967, "y": 514, "z": 1762 };
    
    Puck.magOn();
    
    Puck.on('mag', function(xyz){
      
      xyz.x -= avg.x;
      xyz.y -= avg.y;
      xyz.z -= avg.z;
    
      console.log((Math.atan2(xyz.y, xyz.x) * 180) / Math.PI);
    });
    
  • in Puck.js
    Avatar for gomako

    @user72031 You could have a look at this thread http://forum.espruino.com/conversations/­297915/

  • in Puck.js
    Avatar for gomako

    @Gordon Ah right, yeah I see the distinction between advertising and service now. Will follow this thread with interest, as I think this has such a lot of potential. If you do manage to decode the GATT specs @remy it would be good to hear about it!

  • in Puck.js
    Avatar for gomako

    I follow you to a point, but I don't know what you mean in this bit

    Point the X axis North and take a reading, then point it South and take a reading. Do the same for the Y axis.

    Do I have the puck flat on a level surface and align it to North and South do the X axis (like turning a knob), then do I tip it on it's side and turn it (like a spinning coin) to do the same for Y?

  • in Puck.js
    Avatar for gomako

    I have been trying to advertise as various things from the Puck, but the only things I can get to show up as being described properly in nRF are the examples, Temperature and Battery Life. I can't get blood pressure or environmental sensing to show up. I think you have to provide a byte array as data which has some required parameters for some services, but I don't know how to tell what data it needs or how to give it to it! The eddystone example works too, and that has a load of bytes in an array.

    NRF.setAdvertising([0x03,  // Length of Service List
      0x03,  // Param: Service List
      0xAA, 0xFE,  // Eddystone ID
      0x13,  // Length of Service Data
      0x16,  // Service Data
      0xAA, 0xFE, // Eddystone ID
      0x10,  // Frame type: URL
      0xF8, // Power
      0x03, // https://
      'g','o','o','.','g','l','/','B','3','J',­'0','O','c'],
        {interval:100});
    

    I don't really understand the gatt spec website either.

Actions