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
impl Point
Sourcepub fn xy_rgb(x: i16, y: i16, r: u16, g: u16, b: u16) -> Point
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 }
Sourcepub fn xy_luma(x: i16, y: i16, luminance: u16) -> Point
pub fn xy_luma(x: i16, y: i16, luminance: u16) -> Point
Point CTOR. Use the same intensity value for all color channels.
Sourcepub fn xy_binary(x: i16, y: i16, on: bool) -> Point
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
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}
pub fn serialize(&self) -> Vec<u8> ⓘ
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more