Touch up event

I am running the touch example and notice that the touch up event does not fire except for a couple of times over multiple tests.

Touch down and move events fire as expected.

4.3" inch 800x480 #ER-TFT043A1-7

var configuration = new FBDisplay.Configuration(){
    Clock = 24750,
    Width = 800,
    Hsync_start = 800 + 54,
    Hsync_end = 800 + 54 + 2,
    Htotal = 800 + 54 + 2 + 44,
    Height = 480,
    Vsync_start = 480 + 49,
    Vsync_end = 480 + 49 + 2,
    Vtotal = 480 + 49 + 2 + 22,
    Bus_flags = 68,
};

Continued with the AvaloniaTouch.Desktop.sln sample.

The touch response is delayed. I need to touch the text box multiple times to get the keyboard to appear. On the keyboard I need to touch a letter multiple times to get a keypress.

Without Alonia, touch shoule be fine, but we will check.

With Avalonia, it is heavy, you need to add, touch will be much better

<PublishReadyToRun>true</PublishReadyToRun>

Problem here is when it is enable, some dll can’t debug. That is why we are still looking for different UI. Probally TinyCLR UI or Glide is better.

Touch Up

...
touch.TouchUp += Touch_Event;
...

void Touch_Event(FT5xx6Controller sender, FT5xx6Controller.TouchEventArgs e){
    touchX = e.X;
    touchY = e.Y;
    return;
}

Touch Down

...
touch.TouchDown += Touch_Event;
...

void Touch_Event(FT5xx6Controller sender, FT5xx6Controller.TouchEventArgs e){
    touchX = e.X;
    touchY = e.Y;
    return;
}

With 1.4.0 touch up events are fired but are very very intermittent.

On last video, seems to me it works fine. What is wrong with it?

@Dat_Tran - the last video I posted above was for “Touch Down”. Down works as expected.

“Touch up” has an issue, I see one event for 100s of tries.

We have checked and seems to me it work perfectly. The test is from here: Touch Screen (ghielectronics.com)

(Change FBDisplay.ParallelConfiguration to FBDisplay.Configuration, we will update doc later)

Actually, we use touch up event most of the time when making any demo / applications

touch (youtube.com)

Could it be the screen bad?

Thanks for checking @Dat_Tran

Is your panel 800x480 ?

Hi, it was 480x272, now here is 800x480.

Seems to me it works well

Touch 800x480 (youtube.com)

@Dat_Tran - do you spot anything wrong with the code (this is from the example)

using System.Device.Gpio;
using System.Device.Gpio.Drivers;
using SkiaSharp;
using GHIElectronics.Endpoint.Core;
using GHIElectronics.Endpoint.Devices.Display;
using GHIElectronics.Endpoint.Drivers.FocalTech.FT5xx6;

//Initialize Screen
var screenWidth = 800;
var screenHeight = 480;
var backlightPort = EPM815.Gpio.Pin.PD14 / 16;
var backlightPin = EPM815.Gpio.Pin.PD14 % 16;

var backlightDriver = new LibGpiodDriver((int)backlightPort);
var backlightController = new GpioController(PinNumberingScheme.Logical, backlightDriver);
backlightController.OpenPin(backlightPin);
backlightController.SetPinMode(backlightPin, PinMode.Output);
backlightController.Write(backlightPin, PinValue.High);

var configuration = new FBDisplay.Configuration()
{
    Clock = 24750,
    Width = 800,
    Hsync_start = 800 + 54,
    Hsync_end = 800 + 54 + 2,
    Htotal = 800 + 54 + 2 + 44,
    Height = 480,
    Vsync_start = 480 + 49,
    Vsync_end = 480 + 49 + 2,
    Vtotal = 480 + 49 + 2 + 22,
    Bus_flags = 68,
};
var fbDisplay = new FBDisplay(configuration);
var displayController = new DisplayController(fbDisplay);

//Initialize Touch
var touchX = 0;
var touchY = 0;
var TouchResetPin = EPM815.Gpio.Pin.PF2 % 16;
var TouchResetPort = EPM815.Gpio.Pin.PF2 / 16;
var TouchController = new GpioController(PinNumberingScheme.Logical, new LibGpiodDriver(TouchResetPort));
TouchController.OpenPin(TouchResetPin);
TouchController.Write(TouchResetPin, PinValue.Low);
Thread.Sleep(100);
TouchController.Write(TouchResetPin, PinValue.High);
EPM815.I2c.Initialize(EPM815.I2c.I2c5);
var touch = new FT5xx6Controller(EPM815.I2c.I2c5, EPM815.Gpio.Pin.PB11);

touch.TouchUp += Touch_Event_Up;

//Initialize Graphics
SKBitmap bitmap = new SKBitmap(screenWidth, screenHeight, SKImageInfo.PlatformColorType, SKAlphaType.Premul);
bitmap.Erase(SKColors.Transparent);

while (true)
{
    using (var screen = new SKCanvas(bitmap))
    {

        //Create Black Screen 
        screen.DrawColor(SKColors.Black);
        screen.Clear(SKColors.Black);
        // Draw X
        using (SKPaint text = new SKPaint())
        {
            text.Color = SKColors.White;
            text.IsAntialias = true;
            text.StrokeWidth = 2;
            text.Style = SKPaintStyle.Fill;
            SKFont sKFont = new SKFont();
            sKFont.Size = 60;

            SKTextBlob textBlob = SKTextBlob.Create("Touch X =" + touchX.ToString(), sKFont);
            screen.DrawText(textBlob, 60, 125, text);
        }
        // Draw Y
        using (SKPaint text = new SKPaint())
        {
            text.Color = SKColors.White;
            text.IsAntialias = true;
            text.StrokeWidth = 2;
            text.Style = SKPaintStyle.Fill;
            SKFont sKFont = new SKFont();
            sKFont.Size = 60;

            SKTextBlob textBlob = SKTextBlob.Create("Touch Y =" + touchY.ToString(), sKFont);
            screen.DrawText(textBlob, 60, 175, text);
        }
        // Flush to screen
        var data = bitmap.Copy(SKColorType.Rgb565).Bytes;
        displayController.Flush(data);
        Thread.Sleep(1);
    }
}

void Touch_Event_Up(FT5xx6Controller sender, FT5xx6Controller.TouchEventArgs e)
{
    touchX = e.X;
    touchY = e.Y;
    return;
}

Just out of curiosity, what happens if you try removing the while loop and set your timeout to -1?

I don’t see any wrong with that code, seem my code is same exactly.

FT5xx6Controller => this is from our nuget?

I am worry something wrong with the screen touch controller.

The driver is simple, you can add single file to your project and debug to see:

endpoint-drivers/dotnet/GHIElectronics.Endpoint.Drivers/FocalTech/GHIElectronics.Endpoint.Drivers.FocalTech.FT5xx6/FT5xx6Controller.cs at main · ghi-electronics/endpoint-drivers (github.com)

Without the loop the screen will not be refreshed in this example.

Okay, I see. I haven’t done screen UI yet on the domino.

@Dat_Tran

I am now using FT5xx6Controller as a local file as per your suggestion. I notice that there is an exception thrown every time I touch the panel.

Exception thrown: 'System.IO.IOException' in System.Device.Gpio.dll

Over multiple attempts, I get a touch up event, when that happens there is no Gpio error and the I2C read is as below

0x00,0x00,0x00,0x42,0x2F,0x01,0x33,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00

Byte 3 gives the data for the 1st touch > 0x42 or b01000010

Bit 7:6 give the event flag > b01

b01 indicates “Put Up”