ESP IDF Servo Library

Introduction

This crate is a simple wrapper over the esp-idf-sys bindings to make servo control easier using the LEDC module.

Basic Usage

Create a basic Servo Configuration - this one specific for the SG90 series of servo motors.

``` let peripherals = Peripherals::take().unwrap();

let servocfg = ServoConfig { maxangle: 180, minwidthus: 500, maxwidthus: 2500, frequency: 50, timernumber: ledctimertLEDCTIMER0, pin: peripherals.pins.gpio0.pin(), channel: espidfhal::ledc::CHANNEL0::channel(), speedmode: ledcmodetLEDCLOWSPEED_MODE, }; ```

Initialize the servo:

let servo = Servo::init(servo_cfg);

Change the angle of the servo within your program:

``` loop { for i in 0..180 {

    servo.write_angle((i as f64));

    FreeRtos::delay_ms(20);

    println!("Angle: {}", servo.read_angle());
}

for i in (0..180).rev() {

    servo.write_angle((i as f64));

    FreeRtos::delay_ms(20);

    println!("Angle: {}", servo.read_angle());
}

} ```