Ejemplo n.º 1
0
 private void OnIREvent(IREventArgs e)
 {
     if (IREvent != null)
     {
         IREvent(this, e);
     }
 }
Ejemplo n.º 2
0
        void input_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            bit_time  = time.Ticks - last_tick;
            last_tick = time.Ticks;
            switch (IRReceiverType)
            {
            case ReceiverType.RC5:
                /* When testing revealed that the togglebit not work reliably with fast key action,
                 * hence this is resolved by testing for a bit timeout of 100 ms. This gives better results.*/
                if (bit_time > 1000000)     // 100 ms
                {
                    new_press = true;
                }
                if (bit_time > 26670)      // 3 * halftime (half_bittime = 889 us)
                {
                    bit_time = 0;
                    pattern  = 0;
                    if (data2 == 0)
                    {
                        streaming = true;
                        shiftBit  = 1;
                        pattern  |= shiftBit;
                    }
                    else
                    {
                        streaming = false;
                    }
                    return;
                }
                if (streaming)
                {
                    if (bit_time > 10668)      // = half_bittime * 1.2 (half_bittime = 889 us)
                    {
                        if (data2 == 0)
                        {
                            shiftBit = 1;
                        }
                        else
                        {
                            shiftBit = 0;
                        }
                        pattern <<= 1;
                        pattern  |= shiftBit;
                    }
                    else
                    {
                        if (data2 == 0)
                        {
                            pattern <<= 1;
                            pattern  |= shiftBit;
                        }
                    }
                    if ((pattern & 0x2000) > 0)      // 14 bits
                    {
                        if (new_press)
                        {
                            IREventArgs _args = new IREventArgs();
                            _args.Button   = pattern & 0x3F;
                            _args.ReadTime = DateTime.Now;
                            OnIREvent(_args);
                            new_press = false;
                        }
                        pattern   = 0;
                        bit_time  = 0;
                        streaming = false;
                    }
                }
                break;

            default:
                break;
            }
        }