Completely ported compass to embassy.
This commit is contained in:
		
							parent
							
								
									3471b71dbc
								
							
						
					
					
						commit
						24c8773820
					
				
					 5 changed files with 78 additions and 24 deletions
				
			
		| 
						 | 
				
			
			@ -19,5 +19,6 @@ pub fn draw_constant_heading<const X: usize, const Y: usize>(
 | 
			
		|||
    heading: Heading,
 | 
			
		||||
    matrix: &mut FourQuadrantMatrix<{ X }, { Y }, bool>,
 | 
			
		||||
) {
 | 
			
		||||
    draw_line::<X, Y>(&heading_to_line(heading, X.min(Y)), matrix);
 | 
			
		||||
    matrix.reset_matrix();
 | 
			
		||||
    draw_line::<X, Y>(&heading_to_line(Heading(-heading.0), X.min(Y)), matrix);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,8 +5,10 @@ use core::{
 | 
			
		|||
#[cfg(test)]
 | 
			
		||||
use std::dbg;
 | 
			
		||||
 | 
			
		||||
use defmt::Format;
 | 
			
		||||
 | 
			
		||||
/// a signed point in 2d space
 | 
			
		||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
 | 
			
		||||
#[derive(Debug, Format, Clone, Copy, PartialEq, Eq)]
 | 
			
		||||
pub struct Point {
 | 
			
		||||
    pub x: isize,
 | 
			
		||||
    pub y: isize,
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +27,7 @@ impl Point {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
/// an unsigned point in 2d space
 | 
			
		||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
 | 
			
		||||
#[derive(Debug, Format, Clone, Copy, PartialEq, Eq)]
 | 
			
		||||
pub struct UPoint {
 | 
			
		||||
    pub x: usize,
 | 
			
		||||
    pub y: usize,
 | 
			
		||||
| 
						 | 
				
			
			@ -45,7 +47,7 @@ impl UPoint {
 | 
			
		|||
 | 
			
		||||
/// A matrix that allows negative co-oordinates. Will panic if referencing out of bounds, just like
 | 
			
		||||
/// a normal 2d array.
 | 
			
		||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
 | 
			
		||||
#[derive(Debug, Format, Clone, Copy, PartialEq, Eq)]
 | 
			
		||||
pub struct FourQuadrantMatrix<const X: usize, const Y: usize, T> {
 | 
			
		||||
    matrix: [[T; X]; Y],
 | 
			
		||||
    max_point: Point,
 | 
			
		||||
| 
						 | 
				
			
			@ -139,6 +141,12 @@ impl<T, const X: usize, const Y: usize> From<FourQuadrantMatrix<{ X }, { Y }, T>
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl<'a, T, const X: usize, const Y: usize> From<&'a FourQuadrantMatrix<{ X }, { Y }, T>> for &'a [[T; X]; Y] {
 | 
			
		||||
    fn from(value:&'a FourQuadrantMatrix<{ X }, { Y }, T>) -> Self {
 | 
			
		||||
        &value.matrix
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// a line segment in 2d space, described by its two endpoints
 | 
			
		||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
 | 
			
		||||
pub struct Line(pub Point, pub Point);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue