Crate esp_hal_servo

Crate esp_hal_servo 

Source
Expand description

A library for controlling servo motors using LEDC from esp-hal.

This library provides two approaches for controlling servo motors:

§1. Direct Angle Control

Simply specify the desired angle from the servo’s range and wait for it to reach the position. This is the simplest approach when you know the exact angle you want.

// Set servo to 42 degrees and wait for it to reach the position
servo.set_angle(42.0);

§2. Step-by-Step Control with Direction

Specify the direction of movement and make a step. This approach gives you fine-grained control over the servo movement, allowing you to move it incrementally.

// Set direction to clockwise
servo.set_dir(Dir::CW);
// Make a step of 10 duty units
servo.step(10.0)?;
// Or make a step as a percentage of the total range
servo.step_pct(5)?; // 5% of the range

Modules§

utils
Utility functions for servo calculations. These functions are independent of ServoConfig and can be tested in isolation.

Structs§

Servo
ServoConfig

Enums§

Dir