fix examples for mut self set_duty
This commit is contained in:
parent
903b8f032f
commit
751617c2be
@ -85,7 +85,7 @@ static DUTY: [u16; 1024] = [
|
||||
|
||||
#[embassy::main]
|
||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||
let pwm = SimplePwm::new(p.PWM0, p.P0_13, p.P0_14, p.P0_16, p.P0_15);
|
||||
let mut pwm = SimplePwm::new(p.PWM0, p.P0_13, p.P0_14, p.P0_16, p.P0_15);
|
||||
pwm.set_prescaler(Prescaler::Div1);
|
||||
pwm.set_max_duty(32767);
|
||||
info!("pwm initialized!");
|
||||
|
@ -13,7 +13,7 @@ use embassy_nrf::Peripherals;
|
||||
|
||||
#[embassy::main]
|
||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||
let pwm = SimplePwm::new(p.PWM0, p.P0_13, NoPin, NoPin, NoPin);
|
||||
let mut pwm = SimplePwm::new(p.PWM0, p.P0_13, NoPin, NoPin, NoPin);
|
||||
// set_period doesnt actually set what you give it, because it only has a
|
||||
// few options from the hardhware so be explicit instead
|
||||
// Div128 is slowest, 125khz still crazy fast for our eyes
|
||||
|
@ -13,7 +13,7 @@ use embassy_nrf::Peripherals;
|
||||
|
||||
#[embassy::main]
|
||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||
let pwm = SimplePwm::new(p.PWM0, p.P0_05, NoPin, NoPin, NoPin);
|
||||
let mut pwm = SimplePwm::new(p.PWM0, p.P0_05, NoPin, NoPin, NoPin);
|
||||
// sg90 microervo requires 50hz or 20ms period
|
||||
// set_period can only set down to 125khz so we cant use it directly
|
||||
// Div128 is 125khz or 0.000008s or 0.008ms, 20/0.008 is 2500 is top
|
||||
|
Loading…
Reference in New Issue
Block a user