The Encoder interface is implemented by classes which track an relative position.  
 More...
|  | 
|  | Encoder (EncoderType type, int pin1, int pin2, int i2cAddr) | 
|  | 
|  | Encoder (EncoderType type, int pin1, int pin2, int i2cAddr, boolean group) | 
|  | 
|  | Encoder (EncoderType type, int pin1, int pin2) | 
|  | 
|  | Encoder (EncoderType type, int pin1, int pin2, boolean group) | 
|  | 
| int | getRange () | 
|  | 
| int | get () | 
|  | 
| int | getPosition () | 
|  | 
| int | getSpeed () | 
|  | 
| void | reset () | 
|  | 
| void | reset (int position) | 
|  | 
| void | setZero (int zero) | 
|  | 
| void | setInverted (boolean invert) | 
|  | 
The Encoder interface is implemented by classes which track an relative position. 
- Author
- John Gaby
◆ Encoder() [1/4]
      
        
          | robotCore.Encoder.Encoder | ( | EncoderType | type, | 
        
          |  |  | int | pin1, | 
        
          |  |  | int | pin2, | 
        
          |  |  | int | i2cAddr ) | 
      
 
- Parameters
- 
  
    | type | - Specifies the type of encoder |  | pin1 | - Specifies the first pin that the encoder uses. If it is a quadrature encoder, this must be the interrupt pin |  | pin2 | - Specifies the second pin that the encoder uses (Not use if type is simple) |  | i2cAddr | - Address of i2c arduino which reads encoder |  
 
 
 
◆ Encoder() [2/4]
      
        
          | robotCore.Encoder.Encoder | ( | EncoderType | type, | 
        
          |  |  | int | pin1, | 
        
          |  |  | int | pin2, | 
        
          |  |  | int | i2cAddr, | 
        
          |  |  | boolean | group ) | 
      
 
- Parameters
- 
  
    | type | - Specifies the type of encoder |  | pin1 | - Specifies the first pin that the encoder uses. If it is a quadrature encoder, this must be the interrupt pin |  | pin2 | - Specifies the second pin that the encoder uses (Not use if type is simple) |  | i2cAddr | - Address of i2c microcontroller which reads encoder |  | group | - If this is true, then the reading of the position for this encoder is grouped with other encoders so that a single read will read multiple values. This is done to reduce the i2c speed bottleneck. |  
 
 
 
◆ Encoder() [3/4]
      
        
          | robotCore.Encoder.Encoder | ( | EncoderType | type, | 
        
          |  |  | int | pin1, | 
        
          |  |  | int | pin2 ) | 
      
 
- Parameters
- 
  
    | type | - Specifies the type of encoder |  | pin1 | - Specifies the first pin that the encoder uses. If it is a quadrature encoder, this must be the interrupt pin |  | pin2 | - Specifies the second pin that the encoder uses (Not use if type is simple) |  
 
 
 
◆ Encoder() [4/4]
      
        
          | robotCore.Encoder.Encoder | ( | EncoderType | type, | 
        
          |  |  | int | pin1, | 
        
          |  |  | int | pin2, | 
        
          |  |  | boolean | group ) | 
      
 
- Parameters
- 
  
    | type | - Specifies the type of encoder |  | pin1 | - Specifies the first pin that the encoder uses. If it is a quadrature encoder, this must be the interrupt pin |  | pin2 | - Specifies the second pin that the encoder uses (Not use if type is simple) |  | group | - If this is true, then the reading of the position for this encoder is grouped with other encoders so that a single read will read multiple values. This is done to reduce the i2c speed bottleneck. |  
 
 
 
◆ get()
      
        
          | int robotCore.Encoder.get | ( |  | ) |  | 
      
 
Gets the current encoder value
- Returns
- Returns the current position or speed. In the case of a Rotational encoder the angle is returned in hundredths of a degree 
 
 
◆ getPosition()
      
        
          | int robotCore.Encoder.getPosition | ( |  | ) |  | 
      
 
Gets the current encoder value
- Returns
- Returns the current position 
 
 
◆ getRange()
      
        
          | int robotCore.Encoder.getRange | ( |  | ) |  | 
      
 
Gets the range for the angle encoder
- Returns
- Returns the range for the angle encoder. This is the number that represents 360 degrees. Note that if the encoder is not an absolute angle encoder this function returns zero. 
 
 
◆ getSpeed()
      
        
          | int robotCore.Encoder.getSpeed | ( |  | ) |  | 
      
 
Gets the current encoder value
- Returns
- Returns the current speed 
 
 
◆ reset() [1/2]
      
        
          | void robotCore.Encoder.reset | ( |  | ) |  | 
      
 
Resets the encoder to zero 
 
 
◆ reset() [2/2]
      
        
          | void robotCore.Encoder.reset | ( | int | position | ) |  | 
      
 
Resets the encoder to the specified position.
- Parameters
- 
  
    | position | - Specifies the position to set. In the case of the Rotational encoder this should be the angle in encoder units. |  
 
 
 
◆ setInverted()
      
        
          | void robotCore.Encoder.setInverted | ( | boolean | invert | ) |  | 
      
 
- Parameters
- 
  
    | invert | = If True, the count and speed directions are reversed |  
 
 
 
◆ setZero()
      
        
          | void robotCore.Encoder.setZero | ( | int | zero | ) |  | 
      
 
Sets the zero position for an AnalogRotational encoder.
- Parameters
- 
  
    | zero | - Specifies the encoder value for when the encoder is at it's zero position. |  
 
 
 
The documentation for this class was generated from the following file:
- D:/SDASVN/2025/RaspberryPi/VSCode/Source/robotCore/Encoder.java