device-envoy-rp 0.1.0

Build Pico applications with LED panels, easy Wi-Fi, and composable device abstractions
Documentation
#![allow(missing_docs)]
#![no_std]
#![no_main]

use core::{convert::Infallible, future::pending, panic};
use device_envoy_rp::{Result, servo, servo::Servo as _};
use embassy_executor::Spawner;
use embassy_time::{Duration, Timer};
use {defmt_rtt as _, panic_probe as _};

#[embassy_executor::main]
async fn main(spawner: Spawner) -> ! {
    let err = inner_main(spawner).await.unwrap_err();
    panic!("{err}");
}

async fn inner_main(_spawner: Spawner) -> Result<Infallible> {
    let p = embassy_rp::init(Default::default());

    // Create a servo on GPIO 11.
    // GPIO 11 → (11/2) % 8 = 5 → PWM_SLICE5
    let servo = servo! {
        pin: p.PIN_11,
        slice: p.PWM_SLICE5,
    };

    servo.set_degrees(45); // Move to 45 degrees and hold.
    Timer::after(Duration::from_secs(1)).await; // Give servo reasonable time to reach position
    servo.set_degrees(90); // Move to 90 degrees and hold.
    Timer::after(Duration::from_secs(1)).await; // Give servo reasonable time to reach position
    servo.relax(); // Let the servo relax. It will re-enable on next set_degrees()

    pending().await
}