001/* 002 * Copyright (c) 2018-2022 REV Robotics 003 * 004 * Redistribution and use in source and binary forms, with or without 005 * modification, are permitted provided that the following conditions are met: 006 * 007 * 1. Redistributions of source code must retain the above copyright notice, 008 * this list of conditions and the following disclaimer. 009 * 2. Redistributions in binary form must reproduce the above copyright 010 * notice, this list of conditions and the following disclaimer in the 011 * documentation and/or other materials provided with the distribution. 012 * 3. Neither the name of REV Robotics nor the names of its 013 * contributors may be used to endorse or promote products derived from 014 * this software without specific prior written permission. 015 * 016 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 017 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 018 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 019 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 020 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 021 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 022 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 023 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 024 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 025 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 026 * POSSIBILITY OF SUCH DAMAGE. 027 */ 028 029package com.revrobotics; 030 031/** 032 * @deprecated use {@link AnalogInput} instead (or {@link SparkMaxAnalogSensor} if the analog sensor 033 * is connected directly to a SPARK MAX) 034 */ 035@Deprecated(forRemoval = true) 036public interface CANAnalog extends MotorFeedbackSensor { 037 /** @deprecated Use {@link SparkMaxAnalogSensor.Mode} instead */ 038 @Deprecated(forRemoval = true) 039 enum AnalogMode { 040 kAbsolute(0), 041 kRelative(1); 042 043 @SuppressWarnings("MemberName") 044 public final int value; 045 046 AnalogMode(int value) { 047 this.value = value; 048 } 049 050 public static AnalogMode fromId(int id) { 051 if (id == 1) { 052 return kRelative; 053 } 054 return kAbsolute; 055 } 056 } 057 058 /** 059 * Get the voltage of the analog sensor. 060 * 061 * @return Voltage of the sensor. 062 */ 063 double getVoltage(); 064 065 /** 066 * Get the position of the sensor. Returns value in the native unit of 'volt' by default, and can 067 * be changed by a scale factor using setPositionConversionFactor(). 068 * 069 * @return Position of the sensor in volts 070 */ 071 double getPosition(); 072 073 /** 074 * Get the velocity of the sensor. Returns value in the native units of 'volts per second' by 075 * default, and can be changed by a scale factor using setVelocityConversionFactor(). 076 * 077 * @return Velocity of the sensor in volts per second 078 */ 079 double getVelocity(); 080 081 /** 082 * Set the conversion factor for the position of the analog sensor. By default, revolutions per 083 * volt is 1. Changing the position conversion factor will also change the position units. 084 * 085 * @param factor The conversion factor which will be multiplied by volts 086 * @return {@link REVLibError#kOk} if successful 087 */ 088 REVLibError setPositionConversionFactor(double factor); 089 090 /** 091 * Set the conversion factor for the velocity of the analog sensor. By default, revolutions per 092 * volt second is 1. Changing the velocity conversion factor will also change the velocity units. 093 * 094 * @param factor The conversion factor which will be multiplied by volts per second 095 * @return {@link REVLibError#kOk} if successful 096 */ 097 REVLibError setVelocityConversionFactor(double factor); 098 099 /** 100 * Get the current conversion factor for the position of the analog sensor. 101 * 102 * @return Analog position conversion factor 103 */ 104 double getPositionConversionFactor(); 105 106 /** 107 * Get the current conversion factor for the velocity of the analog sensor. 108 * 109 * @return Analog velocity conversion factor 110 */ 111 double getVelocityConversionFactor(); 112 113 REVLibError setInverted(boolean inverted); 114 115 boolean getInverted(); 116}