Skip to main content

ChipLibrary

Struct ChipLibrary 

Source
pub struct ChipLibrary {
Show 15 fields pub name: String, pub vendor: Option<String>, pub datasheet: Option<String>, pub family_id: u16, pub sub_id: Option<u16>, pub serial_clock: u16, pub chip_control: [u8; 20], pub order: Vec<u8>, pub registers: BTreeMap<u8, [u8; 3]>, pub chip_custom: Option<[u8; 16]>, pub chip_custom_scan_patch: Option<ScanPatch>, pub chip_custom_ex: Option<[u8; 4]>, pub emit_record_84: bool, pub gray_bits: Option<u8>, pub record01_overrides: BTreeMap<usize, u8>,
}

Fields§

§name: String§vendor: Option<String>

Who makes the chip.

§datasheet: Option<String>

Datasheet.

§family_id: u16§sub_id: Option<u16>§serial_clock: u16

Vendor default serial clock for the chip (record +0x021).

§chip_control: [u8; 20]

The 20-byte SChipControl block the vendor’s ResetChipControl emits for this chip (record 0x01 +0x0C4).

§order: Vec<u8>

Register ids in record order. Absent for chips without an addressed register table (the non-SH S-PWM parts, e.g. SM16169S).

§registers: BTreeMap<u8, [u8; 3]>

Register id (spelled 0x.. in the file) → R, G, B values.

§chip_custom: Option<[u8; 16]>

The 16-byte SChipCustom block (record 0x01 +0x06A) when the chip’s configuration lives there instead of in record 0x84. When absent the generator writes only the PWM-flag/serial-clock pair the SH chips use.

§chip_custom_scan_patch: Option<ScanPatch>

The scan patch the vendor applies to chip_custom on load: byte = base | ((scan - 1) & mask) for each listed byte.

§chip_custom_ex: Option<[u8; 4]>

SChipCustomEX (record 0x01 +0x0E0..+0x0E3).

§emit_record_84: bool

The vendor omits record 0x84 for non-addressed chips; a zeroed record is not the same file.

§gray_bits: Option<u8>

Grey depth as a literal, for chips whose depth is not derived from registers 0x07/0x03.

§record01_overrides: BTreeMap<usize, u8>

Record 0x01 bytes this chip id sets differently from the 0x14C baseline; applied before the spec’s own overrides.

Implementations§

Source§

impl ChipLibrary

Source

pub fn load(path: impl AsRef<Path>) -> Result<Self>

§Errors

Fails on a missing or malformed file.

Source

pub fn parse(text: &str) -> Result<Self>

Read a library from TOML text.

§Errors

Fails on malformed TOML, an unknown field or a bad hex key.

Source

pub fn record_84(&self, scan: u8) -> Result<Option<[u8; 256]>>

Record 0x84: (register, R, G, B) quads in library order, zero-filled to 256 bytes, with the vendor’s post-load patch of register 0x02 to scan - 1 (ResetChipCustom, chip 0x14C case).

§Errors

Fails if the order names a register the table lacks, or overflows.

Source

pub fn chip_custom_block(&self, scan: u8) -> Option<[u8; 16]>

The SChipCustom block for a scan count, with the vendor’s load-time patch applied; None for chips configured through record 0x84.

Source

pub fn gray_bits(&self) -> Result<u8>

Grayscale depth the vendor derives from the registers (GetSupporttedGray, chip 0x14C branch): line-gray from reg 0x07 bits 4:3 times a multiplier from reg 0x03, bucketed into 12..16 bits.

§Errors

Fails if registers 0x03 or 0x07 are missing.

Trait Implementations§

Source§

impl Clone for ChipLibrary

Source§

fn clone(&self) -> ChipLibrary

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 Debug for ChipLibrary

Source§

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

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

impl<'de> Deserialize<'de> for ChipLibrary

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

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> 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.