From bf82cfe6dc6816bbe0ffd93efaef2be2f207a795 Mon Sep 17 00:00:00 2001 From: yanorei32 Date: Wed, 11 Oct 2023 01:50:39 +0900 Subject: [PATCH] Drive more smoothly --- src/main.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9dc2584..b306579 100644 --- a/src/main.rs +++ b/src/main.rs @@ -70,11 +70,9 @@ mod app { nb::block!(can.enable_non_blocking()).unwrap(); let (can_tx, can_rx, _) = can.split(); - let can_tx_queue = BinaryHeap::new(); let delay = ctx.device.TIM2.delay_us(&clocks); - let mut gpioc = ctx.device.GPIOC.split(); let led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh); @@ -109,21 +107,21 @@ mod app { loop { for sign in [1, -1] { - for speed in (0..=30) - .chain((0..10).map(|_| 30)) - .chain((0..=30).map(|i| 30 - i)) + 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 * 1000 * sign), + speed2array(speed * 250 * sign), ), ); }); - cx.local.delay.delay(100.millis()); + cx.local.delay.delay(25.millis()); } } }