device_envoy/servo_player/servo_player_generated.rs
1// @generated by `cargo xtask servo-player-generated` or `cargo check-all`. Do not edit by hand.
2//! Module containing [`ServoPlayerGenerated`], the sample struct type generated by the
3//! [`servo_player!`](crate::servo_player!) macro.
4//!
5//! Auto-generated.
6
7#[cfg(all(not(doc), not(feature = "host")))]
8use crate::servo_player;
9
10#[cfg(all(not(doc), not(feature = "host")))]
11servo_player! {
12 pub ServoPlayerGenerated {
13 pin: PIN_11,
14 }
15}
16
17#[cfg(doc)]
18/// Sample struct type generated by the [`servo_player!`](crate::servo_player!) macro, showing all methods and constants.
19///
20/// This page serves as the definitive reference for what a generated servo player type
21/// provides. For first-time readers, start with the examples in the [`servo_player`](mod@crate::servo_player) module
22/// documentation, then return here for a complete list of available methods and
23/// associated constants.
24///
25/// Auto-generated.
26pub struct ServoPlayerGenerated;
27
28#[cfg(doc)]
29use crate::Result;
30#[cfg(doc)]
31use crate::servo_player::AtEnd;
32#[cfg(doc)]
33use embassy_time::Duration;
34
35#[cfg(doc)]
36// Must be public for macro expansion in downstream crates, but not user-facing API.
37#[doc(hidden)]
38/// Static resources for `ServoPlayerGenerated`.
39///
40/// See the [`servo_player`](mod@crate::servo_player) module docs for usage.
41pub struct ServoPlayerGeneratedStatic;
42
43#[cfg(doc)]
44impl ServoPlayerGenerated {
45 /// Maximum number of animation steps allowed.
46 ///
47 /// Specified in the [`servo_player!`](macro@crate::servo_player) macro.
48 pub const MAX_STEPS: usize = 16;
49
50 /// Create static resources.
51 ///
52 /// See the [`servo_player`](mod@crate::servo_player) module docs for usage.
53 #[must_use]
54 #[doc(hidden)]
55 pub const fn new_static() -> ServoPlayerGeneratedStatic {
56 ServoPlayerGeneratedStatic {
57 servo_player_static: ServoPlayerStatic::new_static(),
58 }
59 }
60
61 /// Create a new servo player instance of the struct type
62 /// defined by [`servo_player!`](macro@crate::servo_player).
63 ///
64 /// See the [`servo_player`](mod@crate::servo_player) module docs for usage.
65 ///
66 /// The `pin` and `slice` parameters must correspond to the
67 /// GPIO pin specified in the macro.
68 ///
69 /// # Parameters
70 ///
71 /// - `pin`: GPIO pin for servo
72 /// - `slice`: [PWM slice](crate#glossary) for servo control (`slice = (pin / 2) % 8`)
73 /// - `spawner`: Task spawner for background operations
74 pub fn new(
75 pin: embassy_rp::Peri<'static, embassy_rp::peripherals::PIN_11>,
76 slice: embassy_rp::Peri<'static, embassy_rp::peripherals::PWM_SLICE5>,
77 spawner: embassy_executor::Spawner,
78 ) -> Result<&'static Self> {
79 static INSTANCE: ServoPlayerGenerated = ServoPlayerGenerated;
80 let _ = (pin, slice, spawner);
81 Ok(&INSTANCE)
82 }
83
84 /// Set the target angle. The most recent command always wins.
85 ///
86 /// See the [`servo_player`](mod@crate::servo_player) module docs for usage.
87 pub fn set_degrees(&self, degrees: u16) {
88 let _ = degrees;
89 }
90
91 /// Hold the servo at its current position.
92 ///
93 /// See the [`servo_player`](mod@crate::servo_player) module docs for usage.
94 pub fn hold(&self) {}
95
96 /// Relax the servo. Servo can move freely.
97 ///
98 /// See the [`servo_player`](mod@crate::servo_player) module docs for usage.
99 pub fn relax(&self) {}
100
101 /// Animate the servo through a sequence of angles with per-step hold durations.
102 ///
103 /// Each step is a tuple `(degrees, duration)`. Accepts both owned iterators and
104 /// references to collections.
105 ///
106 /// See the [`servo_player`](mod@crate::servo_player) module docs for usage.
107 pub fn animate<I>(&self, steps: I, at_end: AtEnd)
108 where
109 I: IntoIterator,
110 I::Item: core::borrow::Borrow<(u16, Duration)>,
111 {
112 let _ = (steps, at_end);
113 }
114}