1. Are you ready for the Galaxy S20? Here is everything we know so far!

Bluetooth send scheduling

Discussion in 'Android Development' started by MathewR, Sep 13, 2019.

  1. MathewR

    MathewR Lurker
    Thread Starter

    I am trying to make a control board for a rgbw light that is controlled with my phone over bluetooth. My problem now it that if I move the slider to fast I get garbage data on the output (I included a picture of good and garbage data). My thought was to have it send a bulk data set of the position of all 4 sliders at a scheduled interval to keep it from going to fast. I have looked online but I can't find a way to do it that I understand.
    How I have it setup now is I have a touch listener setup on a Slider so every time the slider is moved it grabs the position and sends it.
    Code (Text):
    1. SliderR.setOnTouchListener(new View.OnTouchListener() {
    2.             @Override
    3.             public boolean onTouch(View view, MotionEvent motionEvent) {
    4.                 GetR();        //method to get position of R
    5.                 RValue1.setText(Short.toString(Rpos));
    6.                 return false;
    7.             }
    8.         });
    Code (Text):
    1. private void GetR(){
    2.         Rpos = (short) SliderR.getProgress();
    3.         if (btSocket!=null)
    4.         {
    5.             try
    6.             {
    7.                 btSocket.getOutputStream().write("R".getBytes());
    8.                 btSocket.getOutputStream().write(Rpos);
    9.             }
    10.             catch (IOException e)
    11.             {
    12.                 msg( "Error");
    13.             }
    14.         }
    15.  
    16.     }
    If you could point me in the right direction to what is should be looking for that would be greatly appreciated.
     

    Attached Files:



  2. Best Answer:
    Post #2 by MathewR, Sep 18, 2019 (1 points)
  3. MathewR

    MathewR Lurker
    Thread Starter

Loading...

Share This Page

Loading...