Enum flipdot::SignType [−][src]
The configuration information for a particular model of sign.
In order to communicate with a sign, we need to send the proper configuration data, which includes an ID, size information, and a few other things. This enum represents the signs for which that data is known, and thus we are able to communicate with.
Examples
use flipdot_core::SignType; let sign_type = SignType::Max3000Front112x16; assert_eq!((112, 16), sign_type.dimensions()); let config = sign_type.to_bytes(); let parsed_type = SignType::from_bytes(config)?; assert_eq!(sign_type, parsed_type);
Format Details
The first byte indicates the type of sign, and different types have different formats for the rest of the configuration block.
Max3000
┌────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┐
│0x04│ ID │0x00│ ?? │ H │ W1 │ W2 │ W3 │ W4 │ B │0x00│0x00│0x00│0x00│0x00│0x00│
└────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┘
Byte 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Max3000 signs have an initial byte of 0x04
. ID
is a unique ID for the particular sign type
within the family, e.g. the 90 × 7 side sign has ID 0x20
. Byte 2 seems to always be zero,
and byte 3 is unknown. H
is the height in pixels, and W1 + W2 + W3 + W4
is the
total width. B
indicates the number of bits per column (either 8 or 16). The remaining
bytes appear unused and are always zero.
Horizon
┌────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┐
│0x08│ ID │0x00│ ?? │ ?? │ H │0x00│ W │ A1 │ A2 │ B1 │ B2 │ ?? │0x00│0x00│0x00│
└────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┘
Byte 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Horizon signs have an initial byte of 0x08
. ID
is a unique ID for the particular sign type
within the family, e.g. the 96 × 8 side sign has ID 0xB4
. Byte 2 seems to always be zero,
and bytes 3 and 4 are unknown. H
is the height in pixels, and W
is the width. The next
four bytes seem to indicate the arrangement of sub-panels to create the final width:
W = A1 × B1 + A2 × B2
. Byte 12 is unknown (generally zero but 0x04
for the 40 × 12 dash sign).
The remaining bytes appear unused and are always zero.
Variants (Non-exhaustive)
Max3000 flip-dot sign, front, 112 × 16 pixels
Max3000 flip-dot sign, front, 98 × 16 pixels
Max3000 flip-dot sign, side, 90 × 7 pixels
Max3000 flip-dot sign, rear, 30 × 10 pixels
Max3000 flip-dot sign, rear, 23 × 10 pixels
Max3000 flip-dot sign, dash, 30 × 7 pixels
Horizon LED sign, front, 160 × 16 pixels
Horizon LED sign, front, 140 × 16 pixels
Horizon LED sign, side, 96 × 8 pixels
Horizon LED sign, rear, 48 × 16 pixels
Horizon LED sign, dash, 40 × 12 pixels
Implementations
impl SignType
[src]
pub fn from_bytes(bytes: &[u8]) -> Result<SignType, SignTypeError>
[src]
Converts a slice representing configuration data into a SignType
.
Errors
Returns:
SignTypeError::WrongConfigLength
if the data is not 16 bytes long.SignTypeError::UnknownConfig
if the data does not correspond to a known sign type.
Examples
let bytes = vec![0x04, 0x62, 0x00, 0x04, 0x0A, 0x1E, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; let sign_type = SignType::from_bytes(&bytes)?; assert_eq!(SignType::Max3000Rear30x10, sign_type);
pub fn dimensions(self) -> (u32, u32)
[src]
Gets the dimensions (width, height), in pixels, of this sign type.
Examples
let sign_type = SignType::HorizonFront140x16; assert_eq!((140, 16), sign_type.dimensions());
pub fn to_bytes(self) -> &'static [u8]
[src]
Gets the 16-byte configuration data for this sign type.
Examples
let sign_type = SignType::Max3000Rear30x10; let expected = vec![0x04, 0x62, 0x00, 0x04, 0x0A, 0x1E, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; assert_eq!(expected, sign_type.to_bytes());
Trait Implementations
impl Clone for SignType
[src]
impl Copy for SignType
[src]
impl Debug for SignType
[src]
impl Eq for SignType
[src]
impl Hash for SignType
[src]
pub fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<SignType> for SignType
[src]
pub fn eq(&self, other: &SignType) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl StructuralEq for SignType
[src]
impl StructuralPartialEq for SignType
[src]
Auto Trait Implementations
impl RefUnwindSafe for SignType
impl Send for SignType
impl Sync for SignType
impl Unpin for SignType
impl UnwindSafe for SignType
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,