// @generated by `cargo check-all`. Do not edit by hand.
//! Module containing [`ServoPlayerGenerated`], the sample struct type generated by the
//! [`servo_player!`](crate::servo_player!) macro.
//!
//! Auto-generated.

#[cfg(doc)]
/// Sample struct type generated by the [`servo_player!`](crate::servo_player!) macro, showing all methods and constants.
///
/// This page serves as the definitive reference for what a generated servo player type
/// provides. For first-time readers, start with the examples in the [`servo`](mod@crate::servo)
/// module documentation, then return here for a complete list of available methods and
/// associated constants.
///
/// Auto-generated.
pub struct ServoPlayerGenerated;

#[cfg(doc)]
use crate::servo::Servo;
#[cfg(doc)]
use crate::servo::{AtEnd, ServoPlayer};
#[cfg(doc)]
use crate::Result;

#[cfg(doc)]
impl ServoPlayerGenerated {
    /// Maximum number of animation steps allowed.
    ///
    /// Specified in the [`servo_player!`](macro@crate::servo::servo_player) macro.
    pub const MAX_STEPS: usize = 16;

    /// Create a new servo player instance of the struct type
    /// defined by [`servo_player!`](macro@crate::servo::servo_player).
    ///
    /// See the [`servo`](mod@crate::servo) module docs for usage.
    ///
    /// The `pin`, `timer`, and `channel` parameters must correspond to the
    /// GPIO/LEDC resources specified in the macro.
    ///
    /// # Parameters
    ///
    /// - `ledc`: [LEDC](crate#glossary) peripheral used to drive PWM
    /// - `pin`: GPIO pin for servo output
    /// - `spawner`: Task spawner for background operations
    pub fn new(
        ledc: &impl Sized,
        pin: impl Sized,
        spawner: embassy_executor::Spawner,
    ) -> Result<&'static Self> {
        static INSTANCE: ServoPlayerGenerated = ServoPlayerGenerated;
        let _ = (ledc, pin, spawner);
        Ok(&INSTANCE)
    }
}

#[cfg(doc)]
impl Servo for ServoPlayerGenerated {
    const DEFAULT_MAX_DEGREES: u16 = 180;

    /// Set the target angle. The most recent command always wins.
    ///
    /// See the [`servo`](mod@crate::servo) module docs for usage.
    fn set_degrees(&self, degrees: u16) {
        let _ = degrees;
    }

    /// Hold the servo at its current position.
    ///
    /// See the [`servo`](mod@crate::servo) module docs for usage.
    fn hold(&self) {}

    /// Relax the servo. Servo can move freely.
    ///
    /// See the [`servo`](mod@crate::servo) module docs for usage.
    fn relax(&self) {}
}

#[cfg(doc)]
impl ServoPlayer<16> for ServoPlayerGenerated {
    const MAX_STEPS: usize = Self::MAX_STEPS;

    /// Animate the servo through a sequence of angles with per-step hold durations.
    ///
    /// Each step is a tuple `(degrees, duration)`. Accepts both owned iterators and
    /// references to collections.
    ///
    /// This uses [`embassy_time::Duration`](https://docs.rs/embassy-time/latest/embassy_time/struct.Duration.html) for step timing.
    ///
    /// See the [`servo`](mod@crate::servo) module docs for usage.
    fn animate<I>(&self, steps: I, at_end: AtEnd)
    where
        I: IntoIterator,
        I::Item: core::borrow::Borrow<(u16, embassy_time::Duration)>,
    {
        let _ = (steps, at_end);
    }
}
