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

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)§

This enum is marked as 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§

source§

impl SignType

source

pub fn from_bytes(bytes: &[u8]) -> Result<Self, SignTypeError>

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);
source

pub fn dimensions(self) -> (u32, u32)

Gets the dimensions (width, height), in pixels, of this sign type.

§Examples
let sign_type = SignType::HorizonFront140x16;
assert_eq!((140, 16), sign_type.dimensions());
source

pub fn to_bytes(self) -> &'static [u8]

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§

source§

impl Clone for SignType

source§

fn clone(&self) -> SignType

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SignType

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Hash for SignType

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for SignType

source§

fn eq(&self, other: &SignType) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for SignType

source§

impl Eq for SignType

source§

impl StructuralPartialEq for SignType

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.