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

RedManchesterCode : Object
ExtensionExtension

Manchester encoding

Description

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

Class Methods

RedManchesterCode.new(numBits: 8)

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.

Inherited class methods

Instance Methods

.encode(bits)

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(value)

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(array)

A method for encoding arrays of numbers.

Arguments:

array

Some array of numbers to be encoded.

Returns:

Same as -encode above

.numBits

.numBits = value

Get or set the number of bits dynamically.

Inherited instance methods

Examples