Enum flipdot::SignType[][src]

#[non_exhaustive]pub enum SignType {
    Max3000Front112x16,
    Max3000Front98x16,
    Max3000Side90x7,
    Max3000Rear30x10,
    Max3000Rear23x10,
    Max3000Dash30x7,
    HorizonFront160x16,
    HorizonFront140x16,
    HorizonSide96x8,
    HorizonRear48x16,
    HorizonDash40x12,
}

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)

Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Max3000Front112x16

Max3000 flip-dot sign, front, 112 × 16 pixels

Max3000Front98x16

Max3000 flip-dot sign, front, 98 × 16 pixels

Max3000Side90x7

Max3000 flip-dot sign, side, 90 × 7 pixels

Max3000Rear30x10

Max3000 flip-dot sign, rear, 30 × 10 pixels

Max3000Rear23x10

Max3000 flip-dot sign, rear, 23 × 10 pixels

Max3000Dash30x7

Max3000 flip-dot sign, dash, 30 × 7 pixels

HorizonFront160x16

Horizon LED sign, front, 160 × 16 pixels

HorizonFront140x16

Horizon LED sign, front, 140 × 16 pixels

HorizonSide96x8

Horizon LED sign, side, 96 × 8 pixels

HorizonRear48x16

Horizon LED sign, rear, 48 × 16 pixels

HorizonDash40x12

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:

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]

impl PartialEq<SignType> for SignType[src]

impl StructuralEq for SignType[src]

impl StructuralPartialEq for SignType[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.