Avatar for user100558

user100558

Member since May 2019 • Last active Jun 2019
  • 2 conversations
  • 5 comments

Most recent activity

    • 7 comments
    • 156 views
  • in Electronics
    Avatar for user100558

    Hi Ollie, thanks for you answer. Yes, my note was connected to the puck. However, I still not figure out how to use the functions to handle the puck features.

    I know that I have to use Puck.write and describe the function that I wanna use in the puck and than the callback. However, I cant for example call 'Puck.on('mag',function(xyv) {' using write. Can I? I saw in examples on internet connecting through IDE that the pages call the functions of puck directly. Like

    var  on = false;
    setInterval(function() {
      on = !on;
      LED1.write(on);
    }, 500);
    

    How I can use javascript like that in my code? Can I?

    Thanks Again

  • in Electronics
    Avatar for user100558

    Hi Guys,

    I was having issues to connect with the espruino, but I was using the wrong code. So, I got how it works create my code, but now I'm receiving a return that my bluetooth is disconnected after connect. It is too weird. Do you know why?
    Follow below my code and the response in chrome

    Code:

    $scope.btnstatus = function(action) {
            var connection;
            if(action == 'on') {
                
                Puck.write('LED1.set();\n',function(call­back) {
                    console.log(callback);
                    Puck.write('Puck.getBatteryPercentage();­\n',function(baterry) {
                        console.log(callback);
                        initMap();
                    })
                });
            }
            else {
                Puck.write('LED1.reset();\n',function() {
                    Puck.write('Puck.magOff();\n',function()­ {
    
                    })
                });
            }
        };
    

    Response:

    Web Bluetooth is experimental on this platform. See https://github.com/WebBluetoothCG/web-bl­uetooth/blob/gh-pages/implementation-sta­tus.md
    puck.js:318 <BLE> Device Name:       Puck.js f0b5
    puck.js:318 <BLE> Device ID:         vtZGyU35qoD8K6UJmjRSEg==
    puck.js:318 <BLE> Connected
    puck.js:318 <BLE> Disconnected (gattserverdisconnected)
    
  • in JavaScript
    Avatar for user100558

    Thanks so much....I totally understand my mistakes.

  • in JavaScript
    Avatar for user100558

    Hi Guys, sorry for my mistake and didn't place the code.

    I'm using cordova with angular v 1.*.

    Follow:

    my head

    <!DOCTYPE html> <html>
        <head>
            <!--
            Customize this policy to fit your own app's needs. For more guidance, see:
                https://github.com/apache/cordova-plugin­-whitelist/blob/master/README.md#content­-security-policy
            Some notes:
                * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
                * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
                * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
                    * Enable inline JS: add 'unsafe-inline' to default-src
            -->
            <meta name="format-detection" content="telephone=no">
            <meta name="msapplication-tap-highlight" content="no">
            <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
            <link rel="stylesheet" type="text/css" href="js/bootstrap/css/bootstrap.min.css­">
            <link rel="stylesheet" href="css/angular-material.min.css">
            <link rel="stylesheet" type="text/css" href="css/index.css">
            <link rel="stylesheet" type="text/css" href="css/specialinputs.css">
            <script type="text/javascript" src="js/jquery-2.2.1.min.js"></script>
            <script type="text/javascript" src="js/bootstrap/js/bootstrap.min.js"><­/script>
            <script src="js/angular.js"></script>
            <script src="js/angular-route.js"></script>
            <script src="js/angular-animate.js"></script>
            <script src="js/angular-aria.min.js"></script>
            <script src="js/angular-messages.min.js"></scrip­t>
            <script src="js/angular-material.min.js"></scrip­t>
            <script src="https://www.puck-js.com/puck.js"></­script>
            <script src="https://maps.googleapis.com/maps/ap­i/js?key=AIzaSyDKO91w7TH8iP4MN1ziQT0BOqj­sWtJtpqk&libraries=places,drawing,geomet­ry" async defer></script>
            <title>Myspot</title>
    

    Then, my code in the angular file.

    scope.btnstatus = function(action) {
            if(action == 'on') {
                Puck.write('LED1.set();\n',function() {
                alert(Puck.getBatteryPercentage());
                initMap();
                });
            }
            else {
                Puck.write('LED1.reset();\n',function() {
                    //Puck.magOff();
                });
            }
        };
    
        $scope.magOn = function() {
            Puck.magOn();
            Puck.on('mag', function(xyz) {
                console.log(xyz);
            });
        }
    
  • in JavaScript
    Avatar for user100558

    Hi,

    I create and small app using angular to connect to the device. It was working to test the LED. However, when I send the command Puck.mag it is getting the error that the function doesnt exit.

    Should I import any other library than puck.js?

    I'm not understand why this error.

    Thanks

Actions