Skip to content

Commit

Permalink
arduino-hal: update delay_ms to match embedded-hal API
Browse files Browse the repository at this point in the history
  • Loading branch information
tones111 committed Jan 2, 2025
1 parent 57ccdae commit 33ee7e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions arduino-hal/src/delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ pub type Delay = avr_hal_generic::delay::Delay<crate::DefaultClock>;
///
/// Busy-loop for the given time. This function assumes the default clock speed defined by
/// [`arduino_hal::DefaultClock`][crate::DefaultClock].
pub fn delay_ms(ms: u16) {
// TODO: update signature to match embedded-hal
Delay::new().delay_ms(ms.into())
pub fn delay_ms(ms: u32) {
Delay::new().delay_ms(ms)
}

/// Delay execution for a number of microseconds.
Expand Down
4 changes: 2 additions & 2 deletions examples/arduino-uno/src/bin/uno-ext-interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn INT0() {
REVERSED.store(!current, Ordering::SeqCst);
}

fn blink_for_range(range: impl Iterator<Item = u16>, leds: &mut [Pin<mode::Output>]) {
fn blink_for_range(range: impl Iterator<Item = u32>, leds: &mut [Pin<mode::Output>]) {
range.map(|i| i * 100).for_each(|ms| {
let iter = if is_reversed() {
Left(leds.iter_mut().rev())
Expand All @@ -35,7 +35,7 @@ fn blink_for_range(range: impl Iterator<Item = u16>, leds: &mut [Pin<mode::Outpu
};
iter.for_each(|led| {
led.toggle();
arduino_hal::delay_ms(ms as u16);
arduino_hal::delay_ms(ms);
})
});
}
Expand Down

0 comments on commit 33ee7e6

Please sign in to comment.