Ejemplo n.º 1
0
  public void forceUpdatePercentage(float percentage, boolean direction) {
    setPercentage(percentage);
    invalidate();

    if (display != null) {
      display.setText(String.format("%.02f", percentage) + "%");
    }
    if (tClient != null) {

      try {
        tClient.sendMessage(
            getServoControlMessage(
                servo, middleValue, offset, direction ? percentage : -1.0 * percentage));
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }
Ejemplo n.º 2
0
  public void updatePercentage(float percentage, boolean direction) {
    setPercentage(percentage);
    invalidate();

    currentTimeMillis = System.currentTimeMillis();
    if (lastTimeMillis < 0 || currentTimeMillis - lastTimeMillis > defaultMessageDelay) {
      lastTimeMillis = currentTimeMillis;

      if (display != null) {
        display.setText(String.format("%.02f", percentage) + "%");
      }
      if (tClient != null) {

        try {
          tClient.sendMessage(
              getServoControlMessage(
                  servo, middleValue, offset, direction ? percentage : -1.0 * percentage));
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    }
  }