Exemplo n.º 1
0
 public virtual void HitTest(
     FT800Device device,
     int value
     )
 {
     //do nothing
 }
Exemplo n.º 2
0
        public static void Main()
        {
            _pd = new OutputPort(Pins.GPIO_PIN_D8, false);

            SPI.Configuration config = new SPI.Configuration(
                SPI_mod: SPI.SPI_module.SPI1,
                ChipSelect_Port: Pins.GPIO_PIN_D10,
                ChipSelect_ActiveState: false,
                ChipSelect_SetupTime: 0,
                ChipSelect_HoldTime: 0,
                Clock_IdleState: false,
                Clock_Edge: true,
                Clock_RateKHz: 10000
                );

            using (SPI spi = new SPI(config))
            {
                var context = new FT800Device(spi, _pd);
                context.Init();

                var w = new Window();
                w.Width           = context.ScreenWidth;
                w.Height          = context.ScreenHeight;
                w.Background      = Colors.DimGray;
                w.BorderColor     = Colors.Gainsboro;
                w.BorderThickness = new Thickness(1);
                WindowService.Instance.MainWindow = w;

                w.Navigate(DemoFont.Create);

                new CalibrationWindow().ShowDialog();

                while (true)
                {
                    WindowService.Instance.Clock(context);
                    Thread.Sleep(100);
                }
            }
        }
Exemplo n.º 3
0
        public void Clock(FT800Device dc)
        {
            if (this._windowCount > 0 &&
                this._windowStack[this._windowCount - 1].Navigator(dc))
            {
                this._invalidation = 3;
            }

            int invalidation = this._invalidation;

            this._invalidation = 0;

            if (invalidation > 2)
            {
                this._lastTag = -1;
            }

            if (invalidation > 1 &&
                this._windowCount > 0)
            {
                var size = new Size(dc.ScreenWidth, dc.ScreenHeight);
                for (int i = 0; i < this._windowCount; i++)
                {
                    Window w;
                    (w = this._windowStack[i]).Measure(size);
                    w.Arrange(new Rect(0, 0, dc.ScreenWidth, dc.ScreenHeight));
                }
            }

            if (invalidation > 0)
            {
                this._hitTagCount = 0;

                var cc = new RenderContext();
                cc.Device = dc;

                dc.BeginCommandTransaction();
                dc.CmdProcessorDlstart();
                //dc.Ft_Gpu_CoCmd_ClearColorRGB(
                //dc.Ft_Gpu_CoCmd_ClearTag(255);
                dc.CmdClear(1, 1, 1);

                for (int i = 0; i < this._windowCount; i++)
                {
                    cc.CurrentIsHitEnabled = i == (this._windowCount - 1);
                    this._windowStack[i].Render(cc, 0, 0);
                }

                dc.CmdProcessorDisplay();
                dc.CmdProcessorSwap();
                dc.EndTransaction();
            }

            if (this._windowCount > 0 &&
                this._hitTagCount > 0)
            {
                int tag;
                if ((tag = (int)dc.ReadUInt32Immediate(FT800Defs.REG_TOUCH_TAG)) > 0)
                {
                    if (this._lastTag >= 0 &&
                        tag <= this._hitTagCount)
                    {
                        uint tracker = dc.ReadUInt32Immediate(FT800Defs.REG_TRACKER);
                        ((FrameworkElement)this._hitTags[tag].Target).HitTest(dc, (int)(tracker >> 16));
                        this._lastTag = tag;
                    }
                }
                else if (this._lastTag > 0)
                {
                    if (this._lastTag <= this._hitTagCount)
                    {
                        ((FrameworkElement)this._hitTags[this._lastTag].Target).HitTest(dc, -1);
                    }

                    this._lastTag = 0;
                }
                else
                {
                    this._lastTag = 0;
                }
            }
        }