Thanks Greg – I’ll take a look at those links, and take on board what you’re 
saying.

From: Gregory Nutt <spudan...@gmail.com>
Reply to: "dev@nuttx.apache.org" <dev@nuttx.apache.org>
Date: Tuesday, 23 May 2023 at 19:52
To: "dev@nuttx.apache.org" <dev@nuttx.apache.org>
Subject: Re: Touchscreen scaling/LVGL


On 5/23/2023 12:11 PM, Tim Hardisty wrote:
Hi,

This is perhaps more a POSIX/general programming question than NuttX but you 
are all, so often, so very helpful :)

A touchscreen peripheral (SAMA5D2 as it happens) delivers X and Y coordinates 
scaled 0-4095.

LVGL wants them scaled to the actual size of the display (800x480 in my case).

I'm not 100% sure that the chip’s TSD driver is the place to scale it?

The TSD driver creates a generic /dev/input0 character driver, which is what 
LVGL (set via Kconfig) opens. Scaling within the LVGL code isn’t right either, 
I don’t think?

I can only think of either:

1) creating a new character driver that does a translation – registered as 
/dev/input1 (or whatever) that LVGL uses, and this driver reads input0 when 
required and returns translated values.

2) Enhance the chip's TSD driver after all, using a Kconfig setting to enable 
X/Y scaling to the display's size (set in board-specific files already).

Both seem a little messy though so perhaps I’m missing something obvious? Can't 
be the first to need to do this?

Thanks,

TimH

Many touchscreens require calibration by the application via a
calibration screen.  Hence, only the application knows the scale factors
to use and so scaling is done by the application.

Scaling could also be done by the driver using calibration information
provided via an IOCTL.  All resistive touchscreens require calibration.
If your touchscreen does not require calibration, then I suppose it
could even be provided by a configuration setting.

Raw, unscaled input is also needed by the application, however (in order
to do calibration, for one).

Scaling in the driver could also be inefficient since the driver does
not know if the sample will be used or not.  It might be better to to
scale in the application even if calibration is not necessary.

A quick Google provides some references for touchscreen calibration with
LVGL:

  * https://forum.lvgl.io/t/calibrate-a-touchscreen-with-tpcal-h/244
  * https://github.com/jakpaul/lvgl_touch_calibration

The are other calibration displays under nutts-apps/ (not for LVGL)

Reply via email to