V1/Toolbox.NETMF.Hardware.InfraredTX/InfraredTransmitter.cs
/// <summary>
/// Adds a pattern of pulses and blanks to the output buffer
/// </summary>
/// <param name="codec">The codec used for the buffer composition</param>
Adds a pattern of pulses and blanks to the output buffer
Adds a pattern of pulses and blanks to the output buffer
internal void Append(InfraredCodecBase codec)
        {
            if (this._lastCodec != codec)
            {
                this._outputCount = 0;
                this._lastCodec = codec;
            }
            int newCount = this._outputCount + codec.TotalPulseCount;
            if (this._outputBuffer.Length < newCount)
            {
                var buffer = new ushort[newCount + 100];
                Array.Copy(
                    this._outputBuffer,
                    buffer,
                    this._outputBuffer.Length);
                this._outputBuffer = buffer;
            }
            const ushort Blank = 0;
            int blankFirst = this._outputCount + codec.InitialPulseCount;
            int blankLast = newCount - codec.FinalPulseCount - 1;
            while (this._outputCount < newCount)
            {
                ushort pattern = (this._outputCount >= blankFirst && this._outputCount <= blankLast)
                    ? Blank
                    : codec.PulseMask;
                this._outputBuffer[_outputCount++] = pattern;
            }
        }
internal void Append ( InfraredCodecBase codec ) { if ( this . _lastCodec != codec ) { this . _outputCount = 0 ; this . _lastCodec = codec ; } int newCount = this . _outputCount + codec . TotalPulseCount ; if ( this . _outputBuffer . Length < newCount ) { var buffer = new ushort [ newCount + 100 ] ; Array . Copy ( this . _outputBuffer , buffer , this . _outputBuffer . Length ) ; this . _outputBuffer = buffer ; } const ushort Blank = 0 ; int blankFirst = this . _outputCount + codec . InitialPulseCount ; int blankLast = newCount - codec . FinalPulseCount - 1 ; while ( this . _outputCount < newCount ) { ushort pattern = ( this . _outputCount >= blankFirst && this . _outputCount <= blankLast ) ? Blank : codec . PulseMask ; this . _outputBuffer [ _outputCount ++ ] = pattern ; } }
Adds a pattern of pulses and blanks to the output buffer
Adds a pattern of pulses and blanks to the output buffer
//check whether the last accessed codec is the same //reset the buffer counter //calculate the new count of the outgoing data //resize the output buffer, if won't fit the newer data /**
             * N = TotalPulseCount
             * offset:  0   +1   +2   +3    ...    N-2  N-1   N
             *      ---------------------------------------------
             *      ##|    |    |    |    |       |    |    |###
             *      ---------------------------------------------
             *        ____________  logic bit  ______________
             **/ //append pulses and blanks to the buffer
codec
InfraredCodecBase
The codec used for the buffer composition
The codec used for the buffer composition