Ejemplo n.º 1
0
        /// <summary>
        /// Creates an IrCode object from Pronto format file bytes.
        /// </summary>
        /// <param name="data">IR file bytes.</param>
        /// <returns>New IrCode object.</returns>
        private static IrCode FromProntoData(byte[] data)
        {
            string code = Encoding.ASCII.GetString(data);

            string[] stringData = code.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            ushort[] prontoData = new ushort[stringData.Length];
            for (int i = 0; i < stringData.Length; i++)
            {
                prontoData[i] = ushort.Parse(stringData[i], NumberStyles.HexNumber);
            }

            IrCode newCode = Pronto.ConvertProntoDataToIrCode(prontoData);

            if (newCode != null)
            {
                newCode.FinalizeData();
            }
            // Seems some old files have excessively long delays in them .. this might fix that problem ...

            return(newCode);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates an IrCode object from old IR file bytes.
        /// </summary>
        /// <param name="data">IR file bytes.</param>
        /// <returns>New IrCode object.</returns>
        private static IrCode FromOldData(byte[] data)
        {
            List <int> timingData = new List <int>();

            int len = 0;

            for (int index = 0; index < data.Length; index++)
            {
                byte curByte = data[index];

                if ((curByte & 0x80) != 0)
                {
                    len += (curByte & 0x7F);
                }
                else
                {
                    len -= curByte;
                }

                if ((curByte & 0x7F) != 0x7F)
                {
                    timingData.Add(len * 50);
                    len = 0;
                }
            }

            if (len != 0)
            {
                timingData.Add(len * 50);
            }

            IrCode newCode = new IrCode(timingData.ToArray());

            newCode.FinalizeData();
            // Seems some old files have excessively long delays in them .. this might fix that problem ...

            return(newCode);
        }
Ejemplo n.º 3
0
    /// <summary>
    /// Creates an IrCode object from old IR file bytes.
    /// </summary>
    /// <param name="data">IR file bytes.</param>
    /// <returns>New IrCode object.</returns>
    private static IrCode FromOldData(byte[] data)
    {
      List<int> timingData = new List<int>();

      int len = 0;

      for (int index = 0; index < data.Length; index++)
      {
        byte curByte = data[index];

        if ((curByte & 0x80) != 0)
          len += (curByte & 0x7F);
        else
          len -= curByte;

        if ((curByte & 0x7F) != 0x7F)
        {
          timingData.Add(len * 50);
          len = 0;
        }
      }

      if (len != 0)
        timingData.Add(len * 50);

      IrCode newCode = new IrCode(timingData.ToArray());
      newCode.FinalizeData();
      // Seems some old files have excessively long delays in them .. this might fix that problem ...

      return newCode;
    }