pub unsafe extern "C" fn adi_encoder_init(
port_top: u8,
port_bottom: u8,
reverse: bool,
) -> adi_encoder_t
Expand description
Creates an encoder object and configures the specified ports accordingly.
This function uses the following values of errno when an error state is reached: ENXIO - The given value is not within the range of ADI Ports EADDRINUSE - The port is not configured as an encoder
\param port_top The “top” wire from the encoder sensor with the removable cover side up. This should be in port 1, 3, 5, or 7 (‘A’, ‘C’, ‘E’, or ‘G’). \param port_bottom The “bottom” wire from the encoder sensor \param reverse If “true”, the sensor will count in the opposite direction
\return An adi_encoder_t object to be stored and used for later calls to encoder functions
\b Example \code #define PORT_TOP 1 #define PORT_BOTTOM 2
void opcontrol() { adi_encoder_t enc = adi_encoder_init(PORT_TOP, PORT_BOTTOM, false); while (true) { printf(“Encoder Value: %d\n”, adi_encoder_get(enc)); delay(5); } } \endcode