diff --git a/crates/servicepoint/src/byte_grid.rs b/crates/servicepoint/src/byte_grid.rs index 0462b90..e02217f 100644 --- a/crates/servicepoint/src/byte_grid.rs +++ b/crates/servicepoint/src/byte_grid.rs @@ -45,10 +45,23 @@ impl ByteGrid { } } + /// Iterate over all cells in `ByteGrid`. + /// + /// Order is equivalent to the following loop: + /// ``` + /// # use servicepoint::{ByteGrid, Grid}; + /// # let grid = ByteGrid::new(2,2); + /// for y in 0..grid.height() { + /// for x in 0..grid.width() { + /// grid.get(x, y) + /// } + /// } + /// ``` pub fn iter(&self) -> Iter { self.data.iter() } + /// Iterate over all rows in `ByteGrid` top to bottom. pub fn iter_rows(&self) -> IterRows { IterRows { byte_grid: self, diff --git a/crates/servicepoint/src/command.rs b/crates/servicepoint/src/command.rs index 856ba9c..b488426 100644 --- a/crates/servicepoint/src/command.rs +++ b/crates/servicepoint/src/command.rs @@ -1,4 +1,4 @@ -use bitvec::prelude::{BitVec, Msb0}; +use bitvec::prelude::BitVec; use crate::command_code::CommandCode; use crate::compression::{into_compressed, into_decompressed}; @@ -27,7 +27,6 @@ pub type Offset = usize; /// Type alias for documenting the meaning of the u16 in enum values pub type Brightness = u8; -// TODO: check order /// A command to send to the display. #[derive(Debug, Clone, PartialEq)] pub enum Command { @@ -369,7 +368,7 @@ impl Command { /// Helper method for Packets into `BitMapLinear*`-Commands fn packet_into_linear_bitmap( packet: Packet, - ) -> Result<(BitVec, CompressionCode), TryFromPacketError> { + ) -> Result<(SpBitVec, CompressionCode), TryFromPacketError> { let Packet(Header(_, _, length, sub, reserved), payload) = packet; if reserved != 0 { return Err(TryFromPacketError::ExtraneousHeaderValues); diff --git a/crates/servicepoint/src/pixel_grid.rs b/crates/servicepoint/src/pixel_grid.rs index 67c8ac6..1ff865d 100644 --- a/crates/servicepoint/src/pixel_grid.rs +++ b/crates/servicepoint/src/pixel_grid.rs @@ -63,10 +63,23 @@ impl PixelGrid { } } + /// Iterate over all cells in `PixelGrid`. + /// + /// Order is equivalent to the following loop: + /// ``` + /// # use servicepoint::{PixelGrid, Grid}; + /// # let grid = PixelGrid::new(8,2); + /// for y in 0..grid.height() { + /// for x in 0..grid.width() { + /// grid.get(x, y) + /// } + /// } + /// ``` pub fn iter(&self) -> Iter<'_, u8, Msb0> { self.bit_vec.iter() } + /// Iterate over all rows in `PixelGrid` top to bottom. pub fn iter_rows(&self) -> IterRows { IterRows { pixel_grid: self, diff --git a/crates/servicepoint_binding_c/src/bit_vec.rs b/crates/servicepoint_binding_c/src/bit_vec.rs index 995d2f6..2592aea 100644 --- a/crates/servicepoint_binding_c/src/bit_vec.rs +++ b/crates/servicepoint_binding_c/src/bit_vec.rs @@ -8,6 +8,7 @@ use servicepoint::bitvec::prelude::{BitVec, Msb0}; /// cbindgen:no-export type SpBitVec = BitVec; +/// Opaque struct needed for correct code generation. #[derive(Clone)] pub struct CBitVec { actual: SpBitVec, diff --git a/crates/servicepoint_binding_c/src/c_slice.rs b/crates/servicepoint_binding_c/src/c_slice.rs index b255c1b..566213d 100644 --- a/crates/servicepoint_binding_c/src/c_slice.rs +++ b/crates/servicepoint_binding_c/src/c_slice.rs @@ -1,3 +1,5 @@ +//! FFI slice helper + #[repr(C)] /// Represents a span of memory (`&mut [u8]` ) as a struct usable by C code. ///