private void SetupCapacitiveTouchController() { var conf = FT5xx6Controller.GetConnectionSettings(); var dev = i2CController.GetDevice(conf); var gpio = gpioController.OpenPin(SC20260.GpioPin.PJ14); //I don't know which pin to use for interrupt touch = new FT5xx6Controller(dev, gpio); //UCMStandard.GpioPin.B - ref:https://docs.ghielectronics.com/hardware/ucm/standard.html#pin-assignments touch.TouchDown += (_, e) => { if (this.CapacitiveScreenPressed != null) { this.CapacitiveScreenPressed(this, new TouchEventArgs(e.X, e.Y)); } }; touch.TouchUp += (_, e) => { if (this.CapacitiveScreenReleased != null) { this.CapacitiveScreenReleased(this, new TouchEventArgs(e.X, e.Y)); } }; touch.TouchMove += (_, e) => { if (this.CapacitiveScreenReleased != null) { this.CapacitiveScreenMove(this, new TouchEventArgs(e.X, e.Y)); } }; }
static void DisplayConfigWPF() { var backlight = GpioController.GetDefault().OpenPin(BACKLIGHT); backlight.SetDriveMode(GpioPinDriveMode.Output); backlight.Write(GpioPinValue.High); var displayController = GHIElectronics.TinyCLR.Devices.Display.DisplayController.GetDefault(); var controllerSetting = new GHIElectronics.TinyCLR.Devices.Display.ParallelDisplayControllerSettings { // 480x272 Width = SCREEN_WIDTH, Height = SCREEN_HEIGHT, DataFormat = GHIElectronics.TinyCLR.Devices.Display.DisplayDataFormat.Rgb565, PixelClockRate = 10000000, PixelPolarity = false, DataEnablePolarity = false, DataEnableIsFixed = false, HorizontalFrontPorch = 2, HorizontalBackPorch = 2, HorizontalSyncPulseWidth = 41, HorizontalSyncPolarity = false, VerticalFrontPorch = 2, VerticalBackPorch = 2, VerticalSyncPulseWidth = 10, VerticalSyncPolarity = false, }; displayController.SetConfiguration(controllerSetting); displayController.Enable(); var i2cController = I2cController.FromName(SC20260.I2cBus.I2c1); var settings = new I2cConnectionSettings(0x38) // the slave's address { BusSpeed = 100000, AddressFormat = I2cAddressFormat.SevenBit, }; var i2cDevice = i2cController.GetDevice(settings); var interrupt = GpioController.GetDefault().OpenPin(TOUCH_IRQ); touch = new FT5xx6Controller(i2cDevice, interrupt); touch.TouchDown += Touch_TouchDown; touch.TouchUp += Touch_TouchUp; // Create WPF window app = new Program(displayController); SelectPage = new SelectPage(); ConnectPage = new ConnectPage(""); SplashPage = new SplashPage(); WpfWindow = Program.CreateWindow(displayController); WpfWindow.Child = SplashPage.Elements; WpfWindow.Visibility = Visibility.Visible; app.Run(WpfWindow); }
public static void InitializeTouch() { var i2cController = I2cController.FromName(SC20260.I2cBus.I2c1); var settings = new I2cConnectionSettings(0x38) { BusSpeed = 100000, AddressFormat = I2cAddressFormat.SevenBit, }; var i2cDevice = i2cController.GetDevice(settings); var gpioController = GpioController.GetDefault(); var interrupt = gpioController.OpenPin(SC20260.GpioPin.PG9); touch = new FT5xx6Controller(i2cDevice, interrupt); touch.TouchDown += Touch_TouchDown; touch.TouchUp += Touch_TouchUp; }
private static void Touch_TouchDown(FT5xx6Controller sender, TouchEventArgs e) => app.InputProvider.RaiseTouch(e.X, e.Y, GHIElectronics.TinyCLR.UI.Input.TouchMessages.Down, System.DateTime.Now);