From 6ce8a12bf818f88692300e74ba3d319c7e107921 Mon Sep 17 00:00:00 2001 From: yanorei32 Date: Wed, 11 Oct 2023 02:54:38 +0900 Subject: [PATCH] Fix for readability --- src/main.rs | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/main.rs b/src/main.rs index b306579..c7f7238 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,7 +14,7 @@ mod app { can::Can, device::TIM2, gpio::{Output, Pin}, - pac::{CAN1, Interrupt}, + pac::{Interrupt, CAN1}, prelude::*, timer::Delay, }; @@ -105,26 +105,25 @@ mod app { fn idle(cx: idle::Context) -> ! { let mut tx_queue = cx.shared.can_tx_queue; - loop { - for sign in [1, -1] { - for speed in (0..=120) - .chain((0..40).map(|_| 120)) - .chain((0..=120).map(|i| 120 - i)) - { - tx_queue.lock(|mut tx_queue| { - enqueue_frame( - &mut tx_queue, - Frame::new_data( - StandardId::new(0x1FF).unwrap(), - speed2array(speed * 250 * sign), - ), - ); - }); + for sign in [1, -1].iter().cycle() { + for speed in (0..=30_000) + .step_by(250) + .chain(core::iter::repeat(30_000).take(1000 / 25)) + .chain((0..=30_000).step_by(250).map(|v| 30_000 - v)) + .map(|v| v * sign) + { + tx_queue.lock(|mut tx_queue| { + enqueue_frame( + &mut tx_queue, + Frame::new_data(StandardId::new(0x1FF).unwrap(), speed2array(speed)), + ); + }); - cx.local.delay.delay(25.millis()); - } + cx.local.delay.delay(25.millis()); } } + + unreachable!() } #[task(binds = USB_HP_CAN_TX, local = [can_tx, led], shared = [can_tx_queue, tx_count])]