Implement TryFrom<u32> for ledc::timer::config::Duty (#1984)
* feat(buzzer): Add `esp-hal-buzzer` to drive a piezo-electric buzzer. Provides a driver for a piezo-electric buzzer by abstracting LEDC and offering a user-friendly API for a buzzer * Move songs into example and refactor songs module. * Move `esp-hal-buzzer` to https://github.com/esp-rs/esp-hal-community/ * Update `CHANGELOG.md` --------- Co-authored-by: Jesse Braham <jesse@beta7.io>
This commit is contained in:
parent
9de459c663
commit
a787a13441
@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- You can now use `Input`, `Output`, `OutputOpenDrain` and `Flex` pins as EXTI and RTCIO wakeup sources (#2095)
|
- You can now use `Input`, `Output`, `OutputOpenDrain` and `Flex` pins as EXTI and RTCIO wakeup sources (#2095)
|
||||||
- Added `Rtc::set_current_time` to allow setting RTC time, and `Rtc::current_time` to getting RTC time while taking into account boot time (#1883)
|
- Added `Rtc::set_current_time` to allow setting RTC time, and `Rtc::current_time` to getting RTC time while taking into account boot time (#1883)
|
||||||
- Added APIs to allow connecting signals through the GPIO matrix. (#2128)
|
- Added APIs to allow connecting signals through the GPIO matrix. (#2128)
|
||||||
|
- Implement `TryFrom<u32>` for `ledc::timer::config::Duty` (#1984)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|||||||
@ -117,6 +117,42 @@ pub mod config {
|
|||||||
Duty20Bit,
|
Duty20Bit,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl TryFrom<u32> for Duty {
|
||||||
|
type Error = ();
|
||||||
|
|
||||||
|
fn try_from(value: u32) -> Result<Self, Self::Error> {
|
||||||
|
Ok(match value {
|
||||||
|
1 => Self::Duty1Bit,
|
||||||
|
2 => Self::Duty2Bit,
|
||||||
|
3 => Self::Duty3Bit,
|
||||||
|
4 => Self::Duty4Bit,
|
||||||
|
5 => Self::Duty5Bit,
|
||||||
|
6 => Self::Duty6Bit,
|
||||||
|
7 => Self::Duty7Bit,
|
||||||
|
8 => Self::Duty8Bit,
|
||||||
|
9 => Self::Duty9Bit,
|
||||||
|
10 => Self::Duty10Bit,
|
||||||
|
11 => Self::Duty11Bit,
|
||||||
|
12 => Self::Duty12Bit,
|
||||||
|
13 => Self::Duty13Bit,
|
||||||
|
14 => Self::Duty14Bit,
|
||||||
|
#[cfg(esp32)]
|
||||||
|
15 => Self::Duty15Bit,
|
||||||
|
#[cfg(esp32)]
|
||||||
|
16 => Self::Duty16Bit,
|
||||||
|
#[cfg(esp32)]
|
||||||
|
17 => Self::Duty17Bit,
|
||||||
|
#[cfg(esp32)]
|
||||||
|
18 => Self::Duty18Bit,
|
||||||
|
#[cfg(esp32)]
|
||||||
|
19 => Self::Duty19Bit,
|
||||||
|
#[cfg(esp32)]
|
||||||
|
20 => Self::Duty20Bit,
|
||||||
|
_ => Err(())?,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Timer configuration
|
/// Timer configuration
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct Config<CS> {
|
pub struct Config<CS> {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user