Skip to main content

SignType

Enum SignType 

Source
#[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<SignType, 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 duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for SignType

Source§

impl Debug for SignType

Source§

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

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

impl Eq for SignType

Source§

impl Hash for SignType

Source§

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

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

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

Source§

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>,

Source§

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>,

Source§

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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.