Struct Point

Source
pub struct Point {
    pub control: u16,
    pub x: i16,
    pub y: i16,
    pub r: u16,
    pub g: u16,
    pub b: u16,
    pub i: u16,
    pub u1: u16,
    pub u2: u16,
}
Expand description

18-byte point data for a single point.

Fields§

§control: u16§x: i16§y: i16§r: u16§g: u16§b: u16§i: u16§u1: u16§u2: u16

Implementations§

Source§

impl Point

Source

pub fn xy_rgb(x: i16, y: i16, r: u16, g: u16, b: u16) -> Point

Point CTOR.

Examples found in repository?
examples/ball.rs (line 65)
53  pub fn get_points(&self, num_points: u16, position: &mut i16) -> Vec<Point> {
54    let mut points = Vec::new();
55    for _i in 0 .. num_points {
56      *position = (*position + 1) % DIV;
57
58      let j = (*position as f64 / DIV as f64) * 2 as f64 * PI;
59      let x = j.cos() * self.radius as f64 + self.x as f64;
60      let y = j.sin() * self.radius as f64 + self.y as f64;
61
62      let x = x as i16;
63      let y = y as i16;
64
65      points.push(Point::xy_rgb(x, y, self.r, self.g, self.b))
66    }
67    points
68  }
Source

pub fn xy_luma(x: i16, y: i16, luminance: u16) -> Point

Point CTOR. Use the same intensity value for all color channels.

Source

pub fn xy_blank(x: i16, y: i16) -> Point

Blank point CTOR.

Source

pub fn xy_binary(x: i16, y: i16, on: bool) -> Point

Point CTOR. If set to on, the lasers are at full power. Otherwise, they’re off.

Examples found in repository?
examples/circle.rs (line 49)
15fn main() {
16  println!("Searching for DAC...");
17
18  let ip_addr = match etherdream::network::find_first_dac() {
19    Err(e) => {
20      println!("Could not find DAC because of error: {}", e);
21      std::process::exit(0);
22    },
23    Ok(result) => {
24      println!("Found DAC at IP: {}", result.ip_address);
25      println!("Broadcast: {:?}", result.broadcast);
26      result.ip_address
27    },
28  };
29
30  let mut dac = Dac::new(ip_addr);
31
32  static mut pos: i32 = 0;
33
34  let _r = dac.play_function(|num_points: u16| {
35    let mut points = Vec::new();
36    for _i in 0 .. num_points {
37      let f = unsafe {
38        pos = (pos + 1) % DIV;
39        pos
40      };
41
42      let j = (f as f64 / DIV as f64) * 2 as f64 * PI;
43      let x = j.cos() * X_MAX as f64;
44      let y = j.sin() * Y_MAX as f64;
45
46      let x = x as i16;
47      let y = y as i16;
48
49      points.push(Point::xy_binary(x, y, true));
50    }
51
52    points
53  });
54}
More examples
Hide additional examples
examples/spiral.rs (line 56)
23fn main() {
24  println!("Searching for DAC...");
25
26  let ip_addr = match etherdream::network::find_first_dac() {
27    Err(e) => {
28      println!("Could not find DAC because of error: {}", e);
29      std::process::exit(0);
30    },
31    Ok(result) => {
32      println!("Found DAC at IP: {}", result.ip_address);
33      println!("Broadcast: {:?}", result.broadcast);
34      result.ip_address
35    },
36  };
37
38  let mut dac = Dac::new(ip_addr);
39
40  static mut pos: i32 = 0;
41
42  let _r = dac.play_function(|num_points: u16| {
43    let mut points = Vec::new();
44    for _i in 0 .. num_points {
45
46      // TODO: Let's build this into etherdream.rs
47      // Get the current point along the beam.
48      // TODO: Also, let's create a `dac.play_stream(S: Stream)`.
49      let f = unsafe {
50        pos = (pos + 1) % (BLANKING_POINTS + SPIRAL_POINTS);
51        pos
52      };
53
54      if f < SPIRAL_POINTS {
55        let (x, y) = get_spiral_point(f);
56        points.push(Point::xy_binary(x, y, true));
57      } else {
58        let (x, y) = get_blanking_point(f - SPIRAL_POINTS);
59        points.push(Point::xy_binary(x, y, false));
60      }
61    }
62
63    points
64  });
65}
Source

pub fn serialize(&self) -> Vec<u8>

Trait Implementations§

Source§

impl Clone for Point

Source§

fn clone(&self) -> Point

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Point

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for Point

Auto Trait Implementations§

§

impl Freeze for Point

§

impl RefUnwindSafe for Point

§

impl Send for Point

§

impl Sync for Point

§

impl Unpin for Point

§

impl UnwindSafe for Point

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.