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

RedDifferentialManchesterCode : Object
ExtensionExtension

Differential manchester encoding

Description

Also known as biphase mark code (BMC). See http://en.wikipedia.org/wiki/Differential_Manchester_encoding

NOTE: There are two classes... one with positive edge clock (RedDifferentialManchesterCode) and one with negative edge clock (RedDifferentialManchesterCodeNegative).

Class Methods

RedDifferentialManchesterCode.new(numBits: 8, initPhase: 0)

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.

initPhase

Initial phase.

Inherited class methods

Instance Methods

.reset

To reset the phase to the initial value.

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

.phase

.phase = value

Get or set the phase dynamically (either 0 or 1).

Inherited instance methods

Examples