Skip to content

Commit

Permalink
Merge branch 'main' into embedded-hal-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkamprath authored Sep 30, 2024
2 parents 2fc1f94 + 1e9c818 commit 04b9634
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ use driver::Driver;
use system::millis::init_millis;
extern crate alloc;


use embedded_alloc::TlsfHeap as Heap;
#[global_allocator]
static HEAP: Heap = Heap::empty();

Expand Down
6 changes: 6 additions & 0 deletions src/robot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ where
cortex_m::interrupt::free(|cs| RIGHT_WHEEL_COUNTER.borrow(cs).get())
}

/// Returns a duty value normalized to the max duty of the motor.
/// The duty is clamped to the range [0, 1].
fn noramlize_duty(&self, duty: f32) -> u16 {
(duty.clamp(0.0, 1.0) * self.motors.enable_pin_a().get_max_duty() as f32) as u16
}

/// returns true if the button 1 is newly pressed
pub fn button1_pressed(&mut self) -> bool {
self.button1.is_newly_pressed()
Expand Down
4 changes: 2 additions & 2 deletions src/system/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ where
///
/// * `f` - The `defmt::Formatter` object that the graph should be printed to.
/// * `value` - A function that gets called on each row in the data table to determine the value from that row to plot.
/// This function must take a reference to the row type and return an `i32`. The mapping of the desired
/// row value to the `i32` is for display purposes.
/// This function must take a reference to the row type and return an `i32`. The mapping of the desired
/// row value to the `i32` is for display purposes.
pub fn plot(&self, f: &mut defmt::Formatter<'_>, value: fn(&T) -> i32) {
// first we need to scan through the data to find the range of
// values that we need to plot
Expand Down

0 comments on commit 04b9634

Please sign in to comment.