Touch calibration: rotating works, scaling fails

1,023 views
Skip to first unread message

Der Achim

unread,
May 17, 2015, 10:05:02 PM5/17/15
to kivy-...@googlegroups.com
Hello.
This is my configuration:

Since the display is in portrait mode, I have also to rotate the touch screen by 90° using config.ini:

[input]
# achim dekativiert: mouse = mouse
# achim deaktiviert (sonst sind 2 touchpads da!); %(name)s = probesysfs,provider=hidinput
<eGalax Inc. Touch> = hidinput,/dev/input/event1,rotation=90,min_position_x=44,min_position_y=90,max_position_x=1992,max_position_y=1992

Using the super-helpful examples/demo/touchtracer, I get the following:

  1. The touch screen is rotated as expected
  2. Calibration does not work. Since my touch screen does not go down to 0 and not all the way up to 2048, I cannot get closer than say 1cm to the border.

However, configuration options in config.ini are obeyed, as displayed during startup of touchtracer:

[INFO              ] HIDInput: Read event from </dev/input/event1>
[INFO              ] HIDInput: Set custom rotation to 90
[INFO              ] HIDInput: Set custom min_position_x to 44
[INFO              ] HIDInput: Set custom min_position_y to 90
[INFO              ] HIDInput: Set custom max_position_x to 1992
[INFO              ] HIDInput: Set custom max_position_y to 1992
[INFO              ] Base: Start application main loop
[INFO              ] HIDMotionEvent: using <eGalax Inc. Touch>
[INFO              ] HIDMotionEvent: <eGalax Inc. Touch> range ABS X position is 0 - 2047
[INFO              ] HIDMotionEvent: <eGalax Inc. Touch> range ABS Y position is 0 - 2047
So why doesn't this work? Is HIDMotionEvent the reasion, since this still goes from 0 . 2047???

Thanks, Achim

(My apologies is this post shows up a second time. But the first time it did not seem to go through.)

Der Achim

unread,
May 19, 2015, 4:33:58 PM5/19/15
to kivy-...@googlegroups.com
Gotcha!
I do not know exactly why and how, but I managed to calibrate my screen.

The bottom line is: It is not the '..._position_...' settings that actually have some influence, but the '..._abs_...' variables. Unfortunately, the latter are not enabled, so we have to do this in the source code.

In kivy/kivy/input/providers/hdinput.py insert the last, marked line:
    class HIDInputMotionEventProvider(MotionEventProvider):
        options
= ('min_position_x', 'max_position_x',
                   
'min_position_y', 'max_position_y',
                   
'min_pressure', 'max_pressure',
                   
'invert_x', 'invert_y', 'rotation',
                   
'min_abs_x', 'max_abs_x', 'min_abs_y', 'max_abs_y') # (achim) added



Then, in config.ini, replace your settings:
[input]
# achim deactivated: mouse = mouse
# achim deactivated (otherwise 2 touchpads show up!); %(name)s = probesysfs,provider=hidinput
#eGalax = hidinput,/dev/input/event1,rotation=90,min_position_x=44,min_position_y=90,max_position_x=1992,max_position_y=1992
# '..._position_...' do not work! insert '..._abs_...' keywords in hdinput.py and use them!
# AND when using rotation=90: x and y refer to the un-rotated coordinates!
eGalax
= hidinput,/dev/input/event1,rotation=90,min_abs_x=60,min_abs_y=90,max_abs_x=1985,max_abs_y=1970

Python will still output wrong settings for 'range ABS X' and 'range ABS Y':
[INFO              ] HIDInput: Read event from </dev/input/event1>
[INFO              ] HIDInput: Set custom rotation to 90
[INFO              ] HIDInput: Set custom min_abs_x to 60
[INFO              ] HIDInput: Set custom min_abs_y to 90
[INFO              ] HIDInput: Set custom max_abs_x to 1985
[INFO              ] HIDInput: Set custom max_abs_y to 1970

[INFO              ] Base: Start application main loop
[INFO              ] HIDMotionEvent: using <eGalax Inc. Touch>
[INFO              ] HIDMotionEvent: <eGalax Inc. Touch> range ABS X position is 0 - 2047
[INFO              ] HIDMotionEvent: <eGalax Inc. Touch> range ABS Y position is 0 - 2047

But calibration is working!

Have a nice day to all,
Achim

qua-non

unread,
Aug 17, 2015, 3:10:16 PM8/17/15
to Kivy users support
@achim you should do a github pull request with your changes, since we don't have access to every touch screen under the sun we rely on good simatirans like you to help us out.

David Goadby

unread,
Feb 25, 2016, 1:51:15 PM2/25/16
to Kivy users support
Hi Achim,

This post of yours has just saved my project - thank you!!!

I have looked everywhere for solutions to my RPi / eGalax touch screen problem. Adding the max_abs_x etc to the config options list in HIDInputMotionEventProvider fixes the problem.

I downloaded the latest Kivy 1.9.1 and the options list in HIDInputMotionEventProvider has not been updated. If no one else has done it I will put a request on github for a change. There are lots of kivy eGalax users looking for this solution so it ought to be done.

Having fixed this aspect of the eGalax problem the next issue is the calibration. The tslib utlitiy ts_calibrate does not help as it doesn't use the frame buffer correctly on my RPi - the test screen is smaller than the full screen that Kivy uses for some reason not yet identified. That said, ts_print_raw is helpful as you can get the coordinates for the four corners of the screen and plant the values into the min_abs_x, max_abs_x, min_abs_y, max_abs_y values in the Kivy config.ini file and it's almost perfect! I also required invert_x.

I am going to look at either a rewrite of ts_print_raw or a fresh Python-based calibrate program for Kivy. Whichever way I do it the Kivy config.ini file needs to be updated to make it possible for end users to calibrate themselves.

I now have a usable eGalax/HDMI 8 inch touch screen working under Kivy. I'm well pleased as QT was looking like a mountain to climb.






Der Achim

unread,
Mar 9, 2016, 4:31:26 PM3/9/16
to Kivy users support
David,
it would be a really helpful job if you could update the HIDInputMotionEventProvider to be compatible with eGalax touch displays. Being a CVS/SVN guy for ages, I struggled with git - and failed miserably. Additionally, I stopped using the RPi, since I had frequent crashes, like once or twice per week. To me it seemd, it was less python/kivy that crashed but more like the whole operating system. I could not bring it to live again and had to reboot. Then I switched to a tablet computer and everything is fine. That's the great thing about kivy: It runs everywhere!
I wish you all the best with your project!
Achim

David Goadby

unread,
Mar 10, 2016, 9:41:32 AM3/10/16
to kivy-...@googlegroups.com
Hi Achim,

I'm using a lot of RPi's now and I don't have any problems with them 24/7 which is good as I am using them in a commercial product. I find the biggest problem is usually the power supply. I have a 12 volt 3A mains power supply followed by a 12 to 5 volt switcher rated at 3A. A lot of people use plug-top power supplies and the quality and actual maximum performance are often less than the label says.

I have posted a request for a change on the Git/Kivy site and we will see what happens. I have also written a calibration program in Kivy to get the final config values correct and update them as required. If you use is as part of an app then you have to reload the config which requires a program restart. At least we have a usable system now and that is a big relief.

Regards

David Goadby

Der Achim wrote:
--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/CZHC6DMEC6c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


This email has been sent from a virus-free computer protected by Avast.
www.avast.com
Reply all
Reply to author
Forward
0 new messages