Exemple #1
0
  public void addLocalSensor(String type, int pinNumber, String tags) {
    boolean notAdded = true;

    if (type.equals("analog")) {
      for (int i = 0; i < totalAnalogSensors; i++) {
        if (analogSensorPin[i] == pinNumber) notAdded = false;
      }
      if (notAdded) {
        localSensor[totalLocalSensors] =
            new LocalSensor(
                ANALOG, pinNumber, tags + ",analogRead" + pinNumber, totalLocalSensors++);
      }
    } else {

      for (int i = 2; i < totalDigitalSensors; i++) {
        if (digitalSensorPin[i] == pinNumber) notAdded = false;
      }

      if (notAdded) {
        localSensor[totalLocalSensors] =
            new LocalSensor(
                DIGITAL, pinNumber, tags + ",digitalRead" + pinNumber, totalLocalSensors++);
        a.pinMode(pinNumber, Arduino.INPUT);
      }
    }
    localSensorsAdded = true;
  }
Exemple #2
0
  public Pachuino(PApplet parent, String device, int speed) {
    System.out.println(
        "\n---------------------\nPachuino version: " + VERSION + "\n---------------------");
    pApplet = parent;

    for (int i = 0; i < Arduino.list().length; i++) {
      System.out.println(Arduino.list()[i]);
    }
    a = new Arduino(parent, device, speed);

    for (int i = 0; i < TOTAL_DIGITAL_IN; i++) {
      a.pinMode(i, Arduino.OUTPUT);
    }

    analogSensorPin = new int[TOTAL_ANALOG_IN];
    digitalSensorPin = new int[TOTAL_DIGITAL_IN];

    remoteFeed = new int[MAX_REMOTE_FEEDS];
    dIn = new DataIn[MAX_REMOTE_FEEDS];

    localSensor = new LocalSensor[TOTAL_ANALOG_IN + TOTAL_DIGITAL_IN];
    remoteSensor = new RemoteSensor[MAX_REMOTE_SENSORS];
    pApplet.registerPre(this);
  }