001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.hal;
006
007import java.nio.IntBuffer;
008
009public class CounterJNI extends JNIWrapper {
010  public static final int TWO_PULSE = 0;
011  public static final int SEMI_PERIOD = 1;
012  public static final int PULSE_LENGTH = 2;
013  public static final int EXTERNAL_DIRECTION = 3;
014
015  public static native int initializeCounter(int mode, IntBuffer index);
016
017  public static native void freeCounter(int counterHandle);
018
019  public static native void setCounterAverageSize(int counterHandle, int size);
020
021  public static native void setCounterUpSource(
022      int counterHandle, int digitalSourceHandle, int analogTriggerType);
023
024  public static native void setCounterUpSourceEdge(
025      int counterHandle, boolean risingEdge, boolean fallingEdge);
026
027  public static native void clearCounterUpSource(int counterHandle);
028
029  public static native void setCounterDownSource(
030      int counterHandle, int digitalSourceHandle, int analogTriggerType);
031
032  public static native void setCounterDownSourceEdge(
033      int counterHandle, boolean risingEdge, boolean fallingEdge);
034
035  public static native void clearCounterDownSource(int counterHandle);
036
037  public static native void setCounterUpDownMode(int counterHandle);
038
039  public static native void setCounterExternalDirectionMode(int counterHandle);
040
041  public static native void setCounterSemiPeriodMode(int counterHandle, boolean highSemiPeriod);
042
043  public static native void setCounterPulseLengthMode(int counterHandle, double threshold);
044
045  public static native int getCounterSamplesToAverage(int counterHandle);
046
047  public static native void setCounterSamplesToAverage(int counterHandle, int samplesToAverage);
048
049  public static native void resetCounter(int counterHandle);
050
051  public static native int getCounter(int counterHandle);
052
053  public static native double getCounterPeriod(int counterHandle);
054
055  public static native void setCounterMaxPeriod(int counterHandle, double maxPeriod);
056
057  public static native void setCounterUpdateWhenEmpty(int counterHandle, boolean enabled);
058
059  public static native boolean getCounterStopped(int counterHandle);
060
061  public static native boolean getCounterDirection(int counterHandle);
062
063  public static native void setCounterReverseDirection(int counterHandle, boolean reverseDirection);
064}