last oops I promise

This commit is contained in:
Grant Miller 2024-09-06 15:08:58 -05:00
parent d24c47a3ff
commit b8beaba6df
6 changed files with 8 additions and 12 deletions

View File

@ -129,7 +129,7 @@ impl<'d, T: GeneralInstance4Channel> SimplePwmChannel<'d, T> {
/// Get the duty for a given channel.
///
/// The value ranges from 0 for 0% duty, to [`max_duty_cycle`](Self::max_duty_cycle) for 100% duty, both included.
pub fn get_duty(&self) -> u16 {
pub fn current_duty_cycle(&self) -> u16 {
unwrap!(self.timer.get_compare_value(self.channel).try_into())
}
@ -300,7 +300,7 @@ impl<'d, T: GeneralInstance4Channel> SimplePwm<'d, T> {
#[allow(clippy::let_unit_value)] // eg. stm32f334
let req = dma.request();
let original_duty_state = self.channel(channel).get_duty();
let original_duty_state = self.channel(channel).current_duty_cycle();
let original_enable_state = self.channel(channel).is_enabled();
let original_update_dma_state = self.inner.get_update_dma_state();
@ -370,7 +370,7 @@ macro_rules! impl_waveform_chx {
let cc_channel = Channel::$cc_ch;
let original_duty_state = self.channel(cc_channel).get_duty();
let original_duty_state = self.channel(cc_channel).current_duty_cycle();
let original_enable_state = self.channel(cc_channel).is_enabled();
let original_cc_dma_on_update = self.inner.get_cc_dma_selection() == Ccds::ONUPDATE;
let original_cc_dma_enabled = self.inner.get_cc_dma_enable_state(cc_channel);

View File

@ -6,7 +6,6 @@ use embassy_executor::Spawner;
use embassy_stm32::gpio::OutputType;
use embassy_stm32::time::khz;
use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm};
use embassy_stm32::timer::Channel;
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};
@ -28,7 +27,7 @@ async fn main(_spawner: Spawner) {
Timer::after_millis(300).await;
ch1.set_duty_cycle_fraction(1, 4);
Timer::after_millis(300).await;
ch1.set_dutycycle_fraction(1, 2);
ch1.set_duty_cycle_fraction(1, 2);
Timer::after_millis(300).await;
ch1.set_duty_cycle(ch1.max_duty_cycle() - 1);
Timer::after_millis(300).await;

View File

@ -84,7 +84,7 @@ async fn main(_spawner: Spawner) {
let pwm_channel = Channel::Ch1;
// make sure PWM output keep low on first start
ws2812_pwm.channel(pwm_channel).set_duty(0);
ws2812_pwm.channel(pwm_channel).set_duty_cycle(0);
// flip color at 2 Hz
let mut ticker = Ticker::every(Duration::from_millis(500));

View File

@ -14,7 +14,6 @@ use embassy_stm32::gpio::{Level, Output, OutputType, Pull, Speed};
use embassy_stm32::time::khz;
use embassy_stm32::timer::pwm_input::PwmInput;
use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm};
use embassy_stm32::timer::Channel;
use embassy_stm32::{bind_interrupts, peripherals, timer};
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};

View File

@ -6,7 +6,6 @@ use embassy_executor::Spawner;
use embassy_stm32::gpio::OutputType;
use embassy_stm32::time::khz;
use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm};
use embassy_stm32::timer::Channel;
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};
@ -28,7 +27,7 @@ async fn main(_spawner: Spawner) {
Timer::after_millis(300).await;
ch1.set_duty_cycle_fraction(1, 4);
Timer::after_millis(300).await;
ch1.set_dutycycle_fraction(1, 2);
ch1.set_duty_cycle_fraction(1, 2);
Timer::after_millis(300).await;
ch1.set_duty_cycle(ch1.max_duty_cycle() - 1);
Timer::after_millis(300).await;

View File

@ -6,7 +6,6 @@ use embassy_executor::Spawner;
use embassy_stm32::gpio::OutputType;
use embassy_stm32::time::khz;
use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm};
use embassy_stm32::timer::Channel;
use embassy_stm32::Config;
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};
@ -39,7 +38,7 @@ async fn main(_spawner: Spawner) {
let ch1_pin = PwmPin::new_ch1(p.PA6, OutputType::PushPull);
let mut pwm = SimplePwm::new(p.TIM3, Some(ch1_pin), None, None, None, khz(10), Default::default());
let mut ch1 = pwm.ch1;
let mut ch1 = pwm.ch1();
ch1.enable();
info!("PWM initialized");
@ -50,7 +49,7 @@ async fn main(_spawner: Spawner) {
Timer::after_millis(300).await;
ch1.set_duty_cycle_fraction(1, 4);
Timer::after_millis(300).await;
ch1.set_dutycycle_fraction(1, 2);
ch1.set_duty_cycle_fraction(1, 2);
Timer::after_millis(300).await;
ch1.set_duty_cycle(ch1.max_duty_cycle() - 1);
Timer::after_millis(300).await;