use bitflags::bitflags;
#[derive(Debug, Clone, PartialEq)]
pub struct Frame {
pub pps: u32,
pub flags: WriteFrameFlags,
pub points: Vec<Point>,
}
impl Frame {
pub fn new(pps: u32, points: Vec<Point>) -> Self {
Frame {
pps,
points,
flags: WriteFrameFlags::empty(),
}
}
pub fn new_with_flags(pps: u32, points: Vec<Point>, flags: WriteFrameFlags) -> Self {
Frame {
pps,
points,
flags
}
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Point {
pub coordinate: Coordinate,
pub color: Color,
pub intensity: u8,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Coordinate {
pub x: u16,
pub y: u16
}
impl From<(u16, u16)> for Coordinate {
fn from((x, y): (u16, u16)) -> Self {
Coordinate { x, y }
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
}
impl Color {
pub fn new(r: u8, g: u8, b: u8) -> Self {
Color {
r,
g,
b
}
}
}
bitflags! {
pub struct WriteFrameFlags: u8 {
const START_IMMEDIATELY = 0b0000_0001;
const SINGLE_MODE = 0b0000_0010;
const DONT_BLOCK = 0b0000_0100;
}
}