pub struct ActuonixLinear<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> { /* private fields */ }Expand description
Generic driver for Actuonix linear actuators (P16, T16).
ReadPos is a closure that returns the raw 12-bit ADC reading (0..4095).
Implementations§
Source§impl<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> ActuonixLinear<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>
impl<const CS_P: char, const CS_N: u8, const SLP_P: char, const SLP_N: u8, const DIS_P: char, const DIS_N: u8, Pwm1, Pwm2, ReadPos> ActuonixLinear<CS_P, CS_N, SLP_P, SLP_N, DIS_P, DIS_N, Pwm1, Pwm2, ReadPos>
Sourcepub fn new<SlpMode, DisMode>(
drv: Drv8873<CS_P, CS_N>,
pwm1: Pwm1,
pwm2: Pwm2,
nsleep: Pin<SLP_P, SLP_N, SlpMode>,
disable: Pin<DIS_P, DIS_N, DisMode>,
read_position: ReadPos,
stroke_len_mm: f32,
buffer_bottom_mm: f32,
buffer_top_mm: f32,
) -> Self
pub fn new<SlpMode, DisMode>( drv: Drv8873<CS_P, CS_N>, pwm1: Pwm1, pwm2: Pwm2, nsleep: Pin<SLP_P, SLP_N, SlpMode>, disable: Pin<DIS_P, DIS_N, DisMode>, read_position: ReadPos, stroke_len_mm: f32, buffer_bottom_mm: f32, buffer_top_mm: f32, ) -> Self
Construct a new Actuonix driver with Hardware PWM.
Sourcepub fn set_speed(&mut self, speed: f32)
pub fn set_speed(&mut self, speed: f32)
Set the motor speed and direction.
speed - A float from -1.0 (Full Retract) to 1.0 (Full Extend).
Sourcepub fn enforce_limits(&mut self)
pub fn enforce_limits(&mut self)
Continuously check the ADC position and brake if the actuator exceeds the software limits. This should be called regularly in the main application loop.
Sourcepub fn is_limit_braking(&self) -> bool
pub fn is_limit_braking(&self) -> bool
True when we are currently braking due to software limit enforcement.
Sourcepub fn position_raw(&mut self) -> u16
pub fn position_raw(&mut self) -> u16
Read raw 12-bit ADC value (0-4095) with hardware oversampling and a median filter.
Sourcepub fn position_percent(&mut self) -> f32
pub fn position_percent(&mut self) -> f32
Read position as a fraction (0.0 = Retracted, 1.0 = Extended).
Sourcepub fn position_mm(&mut self) -> f32
pub fn position_mm(&mut self) -> f32
Read position in millimeters.
Sourcepub fn stroke_len_mm(&self) -> f32
pub fn stroke_len_mm(&self) -> f32
Get the max stroke length.
Sourcepub fn sleep(&mut self)
pub fn sleep(&mut self)
Put the driver into sleep mode.
This shuts down most of the internal circuitry to reduce power consumption.
Sourcepub fn enable_outputs(&mut self)
pub fn enable_outputs(&mut self)
Enable the motor and wake the driver if in sleep.
Sourcepub fn disable_outputs(&mut self)
pub fn disable_outputs(&mut self)
Disable the motor and brake.
Sourcepub fn read_fault<I, PINS>(
&mut self,
spi_bus: &mut SpiBus<I, PINS>,
) -> Result<Fault, Error>where
I: Instance,
PINS: Pins<I>,
pub fn read_fault<I, PINS>(
&mut self,
spi_bus: &mut SpiBus<I, PINS>,
) -> Result<Fault, Error>where
I: Instance,
PINS: Pins<I>,
Read the FAULT status register from the DRV8873.