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 007/** 008 * DutyCycle HAL JNI functions. 009 * 010 * @see "DutyCycle.h" 011 */ 012public class DutyCycleJNI extends JNIWrapper { 013 /** 014 * Initialize a DutyCycle input. 015 * 016 * @param channel the smartio channel 017 * @return the created duty cycle handle 018 * @see "HAL_InitializeDutyCycle" 019 */ 020 public static native int initialize(int channel); 021 022 /** 023 * Free a DutyCycle. 024 * 025 * @param handle the duty cycle handle 026 * @see "HAL_FreeDutyCycle" 027 */ 028 public static native void free(int handle); 029 030 /** 031 * Get the frequency of the duty cycle signal. 032 * 033 * @param handle the duty cycle handle 034 * @return frequency in Hertz 035 * @see "HAL_GetDutyCycleFrequency" 036 */ 037 public static native double getFrequency(int handle); 038 039 /** 040 * Get the output ratio of the duty cycle signal. 041 * 042 * <p>0 means always low, 1 means always high. 043 * 044 * @param handle the duty cycle handle 045 * @return output ratio between 0 and 1 046 * @see "HAL_GetDutyCycleOutput" 047 */ 048 public static native double getOutput(int handle); 049 050 /** 051 * Get the raw high time of the duty cycle signal. 052 * 053 * @param handle the duty cycle handle 054 * @return high time of last pulse in nanoseconds 055 * @see "HAL_GetDutyCycleHighTime" 056 */ 057 public static native int getHighTime(int handle); 058 059 /** Utility class. */ 060 private DutyCycleJNI() {} 061}