Jump to content

New JavaScript Bindings for Test


iia

Recommended Posts

I just added support for multiple graphs in one graph view and implemented it for the Temperature IR Bricklet. I will take a look at the setMode function tomorrow.

 

Edit: I don't like the distance between the two temperature <h3>'s in the new temp ir plugin and the text below the graph is a bit to close. But the good thing is that we can easily beautify the HTML later on, it will then automatically work for all graphs in the plugins ;).

Link zu diesem Kommentar
Share on other sites

  • Replies 61
  • Created
  • Letzte Antwort

Top Posters In This Topic

It works for me. I just used one of our standard examples and called the setMode function:

 

<!DOCTYPE html>
<html>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <head>
        <title>Tinkerforge | JavaScript Example</title>
    </head>
    <body>
        <div style="text-align:center;">
            <h1>Analog Out Bricklet Simple Example</h1>
            <p>
                <input value="localhost" id="host" type="text" size="20">:
                <input value="4280" id="port" type="text" size="5">,
                <input value="uid" id="uid" type="text" size="5">
                <input value="Start Example" id="start" type="button" onclick="startExample();">
            </p>
            <p>
                <textarea id="text" cols="80" rows="24" style="resize:none;"
                          >Press "Start Example" to begin ...</textarea>
            </p>
        <div>
        <script src="./Tinkerforge.js" type='text/javascript'></script>
        <script type='text/javascript'>
            var ipcon;
            var textArea = document.getElementById("text");
            function startExample() {
                textArea.value = "";
                var HOST = document.getElementById("host").value;
                var PORT = parseInt(document.getElementById("port").value);
                var UID = document.getElementById("uid").value;
                if(ipcon !== undefined) {
                    ipcon.disconnect();
                }
                ipcon = new Tinkerforge.IPConnection(); // Create IP connection
                var ao = new Tinkerforge.BrickletAnalogOut(UID, ipcon); // Create device object
                ipcon.connect(HOST, PORT,
                    function(error) {
                        textArea.value += 'Error: '+error+ '\n';
                    }
                ); // Connect to brickd
                // Don't use device before ipcon is connected

                ipcon.on(Tinkerforge.IPConnection.CALLBACK_CONNECTED,
                    function(connectReason) {
                        ao.setMode(Tinkerforge.BrickletAnalogOut.MODE_1K_TO_GROUND);
                    }
                );
            }
        </script>
    </body>
</html>

Link zu diesem Kommentar
Share on other sites

  • 2 weeks later...

Hey guys!

 

I have just downloaded the JS API (I assume it is fresh from the oven, I didn't see it yesterday) and was trying the browser implementation but no go. I cannot seem to connect the device at all, I am always getting error 13. Basically I just copied over the browser implementation JS file and put it to the html files, does it need anything else? I am not using node.js and I haven't tested that version.

 

Your feedback is much appreciated! Thanks.

Link zu diesem Kommentar
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

×   Du hast formatierten Text eingefügt.   Formatierung jetzt entfernen

  Only 75 emoji are allowed.

×   Dein Link wurde automatisch eingebettet.   Einbetten rückgängig machen und als Link darstellen

×   Dein vorheriger Inhalt wurde wiederhergestellt.   Clear editor

×   Du kannst Bilder nicht direkt einfügen. Lade Bilder hoch oder lade sie von einer URL.


×
×
  • Neu erstellen...