001    /*----------------------------------------------------------------------------*/
002    /* Copyright (c) FIRST 2008-2012. All Rights Reserved.                        */
003    /* Open Source Software - may be modified and shared by FRC teams. The code   */
004    /* must be accompanied by the FIRST BSD license file in the root directory of */
005    /* the project.                                                               */
006    /*----------------------------------------------------------------------------*/
007    
008    package edu.wpi.first.wpilibj.communication;
009    
010    import com.sun.cldc.jna.*;
011    
012    /**
013     * Class for calibrating the analog inputs.
014     * @author jhersh
015     */
016    public class AICalibration {
017        //UINT32 FRC_NetworkCommunication_nAICalibration_getLSBWeight(const UINT32 aiSystemIndex, const UINT32 channel, INT32 *status);
018    
019        private static final Function getLSBWeightFn = NativeLibrary.getDefaultInstance().getFunction("FRC_NetworkCommunication_nAICalibration_getLSBWeight");
020    
021        /**
022         * Get the weight of the least significant bit.
023         * @param aiSystemIndex The system index.
024         * @param channel The analog channel.
025         * @return The LSB weight.
026         */
027        public static long getLSBWeight(int aiSystemIndex, int channel) {
028            // TODO: implement error handling if you care.
029            long lsbWeight = getLSBWeightFn.call3(aiSystemIndex, channel, Pointer.NULL()) & 0xFFFFFFFFl;
030            return lsbWeight;
031        }
032        //INT32 FRC_NetworkCommunication_nAICalibration_getOffset(const UINT32 aiSystemIndex, const UINT32 channel, INT32 *status);
033        private static final Function getOffsetFn = NativeLibrary.getDefaultInstance().getFunction("FRC_NetworkCommunication_nAICalibration_getOffset");
034    
035        /**
036         * Get the offset.
037         * @param aiSystemIndex The system index.
038         * @param channel The analog channel.
039         * @return The offset.
040         */
041        public static int getOffset(int aiSystemIndex, int channel) {
042            // TODO: implement error handling if you care.
043            int offset = getOffsetFn.call3(aiSystemIndex, channel, Pointer.NULL());
044            return offset;
045        }
046    }