Esempio n. 1
0
        public override void RobotInit()
        {
            absoluteTach   = new Tachometer(di);
            quadratureTach = new Tachometer(quadDI);
            quadratureTach.EdgesPerRevolution = 2048;
            quadratureCounter                     = new UpDownCounter();
            quadratureCounter.UpSource            = quadDI;
            quadratureCounter.UpEdgeConfiguration = EdgeConfiguration.kRisingEdge;

            externalDirectionCounter = new ExternalDirectionCounter(quadDI, quadDIB);

            externalDirectionCounter2x = new ExternalDirectionCounter(quadDI, quadDIB);
            externalDirectionCounter2x.EdgeConfiguration = EdgeConfiguration.kBothEdges;
            externalDirectionCounter2x.ReverseDirection  = true;

            DigitalGlitchFilter filter = new DigitalGlitchFilter();

            filter.SetPeriod(TimeSpan.FromSeconds(1));
            //filter.Add(di);

            interrupt = new AsynchronousInterrupt(di, (r, f) =>
            {
                Console.WriteLine("Interrupt Occured " + count);
                count++;
                //Thread.Sleep(20);
            });

            interrupt.SetInterruptEdges(true, false);

            interrupt.Enable();
        }
Esempio n. 2
0
    private void DrawNeedle(float angleShift, Texture2D needleTexture)
    {
        float angle = 0;        //angleShift + 3.6f * FlyAndMove.Position.y;

        // rotation point in texture added with x and y
        // needle: 16x16, texture: 128x128 > center: 64x64 + 16 = 80
        Vector2 rotationPoint = new Vector2(0.5f * Screen.width + 80f, Screen.height - 80f);

        Rect rect = new Rect(0.5f * Screen.width + 16f, Screen.height - 144f, 128f, 128f);

        Tachometer.DrawNeedle(angle, rotationPoint, rect, needleTexture);
    }
        void Receiver_OnEventInit(object sender, DataEventArgs <GPBikes.SPluginsBikeEvent_t> e)
        {
            Dispatcher.Invoke((Action)(() =>
            {
                Tachometer.MajorDivisionsCount = Tachometer.MaxValue = (int)(e.Data.MaxRPM / 1000d) + 1;
                Tachometer.OptimalRangeEndValue = e.Data.ShiftRPM / 1000d;

                // gauge is setup up so that ShiftRPM points to sky:
                //    13500RPM --> 45 degrees
                Tachometer.ScaleStartAngle = 45d + (13500 - e.Data.ShiftRPM) / 30;

                Tachometer.RefreshScale();
            }));
        }