LED closing when disconnected

edited March 2015 in Android
Hi! I am trying to change LED light color when I disconnect from the board. I use ledCtrllr.play(false) function but nothing happens.
It has to be inside a Device Callback or something? I only have figured out to open the led when I connect to metawear

Here is the code :
private DeviceCallbacks dCallbacks= new DeviceCallbacks() {

     

        @Override

        public void connected() {

            Log.i("ExampleActivity", "A Bluetooth LE connection has been established!");

            ledCtrllr= (LED) mwCtrllr.getModuleController(Module.LED);

            ledCtrllr.stop(true);

            playCyan(ledCtrllr); 

        }

     

        @Override

        public void disconnected() {

            Log.i("ExampleActivity", "Lost the Bluetooth LE connection!");

            

        }

    };



And playCyan is this one

    private void playCyan(LED ledCtrllr) {

    short pulseWidth= 2000;

    ledCtrllr.setColorChannel(ColorChannel.BLUE).withHighIntensity((byte) 31)

            .withHighTime(pulseWidth).withPulseDuration(pulseWidth)

            .withRepeatCount((byte) -1).commit();

        ledCtrllr.setColorChannel(ColorChannel.GREEN).withHighIntensity((byte) 31)

                .withHighTime(pulseWidth).withPulseDuration(pulseWidth)

                .withRepeatCount((byte) -1).commit();

     

    

        ledCtrllr.play(false);

    }




Any idea?


Comments

  • edited March 2015
    I have also tried to change LED state when detects an orientation change but it doesn't work either. It detects the movement (I see the log) but there's no change in LED

    Here the code
    mwCtrllr.addModuleCallback(new Accelerometer.Callbacks() {

                @Override

                public void orientationChanged(Orientation accelOrientation) {

                    Log.i("ExampleActivity", String.format(Locale.US, "Orientation= %s", 

                            accelOrientation));

                   

                    playYellow( (LED) mwCtrllr.getModuleController(Module.LED)); 

                    

       

            });

  • edited March 2015
    Finally I have also try to change behaviour with a button that calls this function

     public void change(View view) {

        switch(color){

         case(0): playGreen(ledController); Log.i("Change",""+color); color++; break;

         case(1): playYellow(ledController); Log.i("Change",""+color); color++; break;

         case(2): playCyan(ledController); Log.i("Change",""+color); color++; break;

         case(3): playMagenta(ledController); Log.i("Change",""+color); color=0; break;

         }

    }


    Doesn't work too :(

  • Try calling the play method with true instead of false to enable autoplay.
  • doesn't work either... :(
This discussion has been closed.