1use bitflags::bitflags;
2
3#[derive(Debug, Clone, PartialEq)]
4pub struct Frame {
5 pub pps: u32,
7 pub flags: WriteFrameFlags,
9 pub points: Vec<Point>,
10}
11
12impl Frame {
13 pub fn new(pps: u32, points: Vec<Point>) -> Self {
14 Frame {
15 pps,
16 points,
17 flags: WriteFrameFlags::empty(),
18 }
19 }
20
21 pub fn new_with_flags(pps: u32, points: Vec<Point>, flags: WriteFrameFlags) -> Self {
22 Frame {
23 pps,
24 points,
25 flags
26 }
27 }
28}
29
30#[derive(Debug, Clone, Copy, PartialEq)]
31pub struct Point {
32 pub coordinate: Coordinate,
33 pub color: Color,
34 pub intensity: u8,
35}
36
37#[derive(Debug, Clone, Copy, PartialEq)]
41pub struct Coordinate {
42 pub x: u16,
43 pub y: u16
44}
45
46impl From<(u16, u16)> for Coordinate {
47 fn from((x, y): (u16, u16)) -> Self {
48 Coordinate { x, y }
49 }
50}
51
52#[derive(Debug, Clone, Copy, PartialEq)]
53pub struct Color {
54 pub r: u8,
56 pub g: u8,
58 pub b: u8,
60}
61
62impl Color {
63 pub fn new(r: u8, g: u8, b: u8) -> Self {
64 Color {
65 r,
66 g,
67 b
68 }
69 }
70}
71
72bitflags! {
73 pub struct WriteFrameFlags: u8 {
74 const START_IMMEDIATELY = 0b0000_0001;
76 const SINGLE_MODE = 0b0000_0010;
78 const DONT_BLOCK = 0b0000_0100;
80 }
81}
82