• Hi Guys, a new Puck.js plugin now available for DroidScript.

    You can now very easily make Android apps using JavaScript to remotely control and program your Puck. This plugin also works with older Android devices (as long as they support BLE).

    You can use the plugin in your apps to remotely control all functions of your Puck by sending JavaScript code to the interpreter inside the Puck via bluetooth. You can also receive the console output of your Puck programs to get information back to your app.

    Although you can send raw JavaScript code to the Puck using the SendCode method, in many cases you may prefer to use the built-in convenience methods provided by this plugin. These methods allow you easily perform common tasks such as controlling the LEDs, reading the battery level, detecting button presses and getting the temperature, setting the NFC url etc.

    The plugin docs also contains convenient run-able samples, including a simple Puck programmer.

    Download DroidScript an have a go... it's free and incredibly easy to use.

    Please give us feedback regarding the Puck.js plugin on the DroidScript forum:-
    groups.google.com/forum/?fromgro­ups=#!forum/androidscript

    Regards
    David

  • Great, thanks!

    Out of interest, does this work on Android 4+5 devices too? I've found Web Bluetooth doesn't work on Android 4, and Chromium (which is needed for Android 5) is sometimes a bit sketchy on it

  • Hi Gordon,

    It should work for Android 4.3 (JellyBean) devices and onwards and should not require any updates to Chromium since it uses native SDK calls (not Web Bluetooth)

  • Sounds great - thanks! If you wanted to do some kind of intro video or tutorial I'd be happy to stick it in the site.

  • Wow - this is great and simple

    Testing with a Huawei P8 lite with Android version 5.0.1 and using the build in WebIDE for coding and starting the scripts over a notebook browser, check screenshot.


    1 Attachment

    • Bildschirmfoto 2016-12-19 um 20.03.57.JPG
  • Sadly this is not working on my Samsung Galaxy 4 Ace (Model SM-G357F) which runs Android 4.4.4. This phone runs some Android apps that must use similar functions eg. nRF Uart and Bluefruit LE but I have encountered issues that prevent me using nRF Toolbox and some other BLE related apps. I will however mention on the droidscript forum too.

  • This is great for whipping up a quick GUI on your phone to control something on the Puck. Here are two very simple examples that don't need any special code on the Puck to work.

    app.LoadPlugin( "PuckJS" );
    
    function OnStart()
    {
      lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
      btn1 = app.CreateToggle( "LED1" );
      btn2 = app.CreateToggle( "LED2" );
      btn3 = app.CreateToggle( "LED3" );
      btn1.SetOnTouch( btn1_OnTouch );
      btn2.SetOnTouch( btn2_OnTouch );
      btn3.SetOnTouch( btn3_OnTouch );
      lay.AddChild( btn1 );
      lay.AddChild( btn2 );
      lay.AddChild( btn3 );
      app.AddLayout( lay );
    
      puck = app.CreatePuckJS();
     // puck.Scan( "Puck" );
     puck.Connect('AA:BB:CC:DD:EE:FF');
    }
    
    function btn1_OnTouch( isChecked )
    {
      puck.SetLED( 1, isChecked );
    }
    function btn2_OnTouch( isChecked )
    {
      puck.SetLED( 2, isChecked );
    }
    function btn3_OnTouch( isChecked )
    {
      puck.SetLED( 3, isChecked );
    }
    
    app.LoadPlugin( "PuckJS" );
    var on= false;
    var intr;
    function OnStart()
    {
      lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
      btn1 = app.CreateToggle( "LED1" );
      btn1.SetOnTouch( btn1_OnTouch );
      lay.AddChild( btn1 );
      app.AddLayout( lay );
      puck = app.CreatePuckJS();
      puck.Connect('AA:BB:CC:DD:EE:FF');
    }
    
    function btn1_OnTouch( isChecked )
    {
      if (isChecked) {
       intr= setInterval('on=!on;puck.SetLED(1, on)', 500);
      }
     else {
        clearInterval(intr);
        puck.SetLED(1, false);
      }
    }
    

    Andrew

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Make simple Android apps to control Puck.js with the new plugin for DroidScript

Posted by Avatar for Dave_Smart @Dave_Smart

Actions