RedManchesterCode:
Filter:
redSys/Classes (extension) | Red > redTools

RedManchesterCode
ExtensionExtension

Manchester encoding

Description

As per IEEE 802.3. See http://en.wikipedia.org/wiki/Manchester_encoding

Class Methods

.new

Creates a new encoder.

Arguments:

numBits

The maximum number of bits in the data to be encoded. The default 8 can deal with values between 0 and 255.

Instance Methods

.encode

The lowest level method for encoding. Give and return arrays with raw 0/1 bits.

Arguments:

bits

An array of raw bits (zeros and ones) representing the n-bit value to be encoded. The length of this array should match numBits.

Returns:

An array of raw bits (zeros and ones) with encoded clock and data bits.

NOTE: The array returned will be double in length of the argument array (and also 2*numBits in length).

.encodeValue

A method for encoding single numbers. Converts the number to bits and then calls -encode.

Arguments:

value

Some number to be encoded. Make sure to not go above the current set numBits capacity (0-255 by default).

Returns:

Same as -encode above

.encodeArray

A method for encoding arrays of numbers.

Arguments:

array

Some array of numbers to be encoded.

Returns:

Same as -encode above

.numBits

Get or set the number of bits dynamically.

Examples