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 * Power HAL JNI Functions. 009 * 010 * @see "Power.h" 011 */ 012public class PowerJNI extends JNIWrapper { 013 /** 014 * Gets the roboRIO input voltage. 015 * 016 * @return the input voltage (volts) 017 * @see "HAL_GetVinVoltage" 018 */ 019 public static native double getVinVoltage(); 020 021 /** 022 * Gets the 3V3 rail voltage. 023 * 024 * @return the 3V3 rail voltage (volts) 025 * @see "HAL_GetUserVoltage3V3" 026 */ 027 public static native double getUserVoltage3V3(); 028 029 /** 030 * Gets the 3V3 rail current. 031 * 032 * @return the 3V3 rail current (amps) 033 * @see "HAL_GetUserCurrent3V3" 034 */ 035 public static native double getUserCurrent3V3(); 036 037 /** 038 * Enables or disables the 3V3 rail. 039 * 040 * @param enabled whether the rail should be enabled 041 */ 042 public static native void setUserEnabled3V3(boolean enabled); 043 044 /** 045 * Gets the active state of the 3V3 rail. 046 * 047 * @return true if the rail is active, otherwise false 048 * @see "HAL_GetUserActive3V3" 049 */ 050 public static native boolean getUserActive3V3(); 051 052 /** 053 * Gets the fault count for the 3V3 rail. 054 * 055 * @return the number of 3V3 fault counts 056 * @see "HAL_GetUserCurrentFaults3V3" 057 */ 058 public static native int getUserCurrentFaults3V3(); 059 060 /** Resets the overcurrent fault counters for all user rails to 0. */ 061 public static native void resetUserCurrentFaults(); 062 063 /** 064 * Set the voltage the roboRIO will brownout and disable all outputs. 065 * 066 * <p>Note that this only does anything on the roboRIO 2. On the roboRIO it is a no-op. 067 * 068 * @param voltage The brownout voltage 069 * @see "HAL_SetBrownoutVoltage" 070 */ 071 public static native void setBrownoutVoltage(double voltage); 072 073 /** 074 * Get the current brownout voltage setting. 075 * 076 * @return The brownout voltage 077 * @see "HAL_GetBrownoutVoltage" 078 */ 079 public static native double getBrownoutVoltage(); 080 081 /** 082 * Get the current CPU temperature in degrees Celsius. 083 * 084 * @return current CPU temperature in degrees Celsius 085 */ 086 public static native double getCPUTemp(); 087 088 /** Utility class. */ 089 private PowerJNI() {} 090}