Drive more smoothly
This commit is contained in:
		
							
								
								
									
										12
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/main.rs
									
									
									
									
									
								
							@@ -70,11 +70,9 @@ mod app {
 | 
				
			|||||||
        nb::block!(can.enable_non_blocking()).unwrap();
 | 
					        nb::block!(can.enable_non_blocking()).unwrap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let (can_tx, can_rx, _) = can.split();
 | 
					        let (can_tx, can_rx, _) = can.split();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        let can_tx_queue = BinaryHeap::new();
 | 
					        let can_tx_queue = BinaryHeap::new();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let delay = ctx.device.TIM2.delay_us(&clocks);
 | 
					        let delay = ctx.device.TIM2.delay_us(&clocks);
 | 
				
			||||||
 | 
					 | 
				
			||||||
        let mut gpioc = ctx.device.GPIOC.split();
 | 
					        let mut gpioc = ctx.device.GPIOC.split();
 | 
				
			||||||
        let led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh);
 | 
					        let led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -109,21 +107,21 @@ mod app {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        loop {
 | 
					        loop {
 | 
				
			||||||
            for sign in [1, -1] {
 | 
					            for sign in [1, -1] {
 | 
				
			||||||
                for speed in (0..=30)
 | 
					                for speed in (0..=120)
 | 
				
			||||||
                    .chain((0..10).map(|_| 30))
 | 
					                    .chain((0..40).map(|_| 120))
 | 
				
			||||||
                    .chain((0..=30).map(|i| 30 - i))
 | 
					                    .chain((0..=120).map(|i| 120 - i))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    tx_queue.lock(|mut tx_queue| {
 | 
					                    tx_queue.lock(|mut tx_queue| {
 | 
				
			||||||
                        enqueue_frame(
 | 
					                        enqueue_frame(
 | 
				
			||||||
                            &mut tx_queue,
 | 
					                            &mut tx_queue,
 | 
				
			||||||
                            Frame::new_data(
 | 
					                            Frame::new_data(
 | 
				
			||||||
                                StandardId::new(0x1FF).unwrap(),
 | 
					                                StandardId::new(0x1FF).unwrap(),
 | 
				
			||||||
                                speed2array(speed * 1000 * sign),
 | 
					                                speed2array(speed * 250 * sign),
 | 
				
			||||||
                            ),
 | 
					                            ),
 | 
				
			||||||
                        );
 | 
					                        );
 | 
				
			||||||
                    });
 | 
					                    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    cx.local.delay.delay(100.millis());
 | 
					                    cx.local.delay.delay(25.millis());
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user