Hi Ashwin, Instead of integrating TSLIB into Android you can use a simple Android application that works like ts_calibrate (TSLIB test app) to get calibration values.
Regards On Mon, May 23, 2011 at 6:46 PM, Ashwin Bihari <[email protected]> wrote: > Gaurav, > > This is great, did you look into integrating TSLIB directly into > Android/Gingerbread instead of sucking in just the calibration values? > > -- Ashwin > > > > On Mon, May 23, 2011 at 1:34 AM, Gaurav Singh <[email protected]> wrote: >> I have a resistive touchscreen with mechanical misalignments on my >> board. The "5 point calibration method" solves errors caused by these >> misalignments and converts Touchscreen controller data to actual >> screen coordinates. A complete description of mechanical misalignments >> and 5 point calibration method can be found at >> http://focus.tij.co.jp/jp/lit/an/slyt277/slyt277.pdf. >> >> 5-point calibration method is part of the TSLIB touchscreen >> calibration commonly used for our QT based devices. We can extend >> Android's touchscreen Calibration parameters to include the 6 >> parameters that are part of the /etc/pointercal file ( calculated when >> we run ts_calibrate on TSLIB). Sample idc file below: >> >> # See output of /etc/pointercal file after running ts_calibrate on normal >> Linux >> # >> # Before running ts_calibrate - >> # export TSLIB_TSDEVICE=/dev/input/event1 >> # export TSLIB_CALIBFILE=/etc/pointercal >> # export TSLIB_CONFFILE=/etc/ts.conf >> # export TSLIB_FBDEVICE=/dev/fb0 >> # >> # Pointercal file format - xscale, xymix, xoffset, yxmix, yscale, >> yoffset, divider. >> # Enter here the values after dividing xscale etc. with the divider. >> # >> >> touch.5pointcalib.xscale = 0.199488 >> touch.5pointcalib.xymix = -0.000325 >> touch.5pointcalib.xoffset = -6.898865 >> touch.5pointcalib.yxmix = -0.000795 >> touch.5pointcalib.yscale = 0.124000 >> touch.5pointcalib.yoffset = -8.484802 >> >> I patched the Android Input subsystem to include the 5 point >> calibration method for generating actual screen coordinates. >> Gingerbread currently uses simple scaling of touchscreen X and Y data >> to CLCD screen X and Y coordinates. In frameworks/base made the >> following changes : >> >> diff --git a/include/ui/InputReader.h b/include/ui/InputReader.h >> index 49351b0..bb3ec5e 100644 >> --- a/include/ui/InputReader.h >> +++ b/include/ui/InputReader.h >> @@ -589,6 +589,20 @@ protected: >> >> // Immutable calibration parameters in parsed form. >> struct Calibration { >> + // 5 point calibration algorithm coefficients >> + bool havexscale; >> + float xscale; >> + bool havexymix; >> + float xymix; >> + bool havexoffset; >> + float xoffset; >> + bool haveyxmix; >> + float yxmix; >> + bool haveyscale; >> + float yscale; >> + bool haveyoffset; >> + float yoffset; >> + >> // Touch Size >> enum TouchSizeCalibration { >> TOUCH_SIZE_CALIBRATION_DEFAULT, >> diff --git a/libs/ui/InputReader.cpp b/libs/ui/InputReader.cpp >> index 3197ab2..9345dca 100644 >> --- a/libs/ui/InputReader.cpp >> +++ b/libs/ui/InputReader.cpp >> @@ -1682,6 +1682,20 @@ void TouchInputMapper::parseCalibration() { >> const InputDeviceCalibration& in = getDevice()->getCalibration(); >> Calibration& out = mCalibration; >> >> + out.havexscale = in.tryGetProperty(String8("touch.5pointcalib.xscale"), >> + out.xscale); >> + out.havexymix = in.tryGetProperty(String8("touch.5pointcalib.xymix"), >> + out.xymix); >> + out.havexoffset = >> in.tryGetProperty(String8("touch.5pointcalib.xoffset"), >> + out.xoffset); >> + out.haveyxmix = in.tryGetProperty(String8("touch.5pointcalib.yxmix"), >> + out.yxmix); >> + out.haveyscale = in.tryGetProperty(String8("touch.5pointcalib.yscale"), >> + out.yscale); >> + out.haveyoffset = >> in.tryGetProperty(String8("touch.5pointcalib.yoffset"), >> + out.yoffset); >> + >> + >> // Touch Size >> out.touchSizeCalibration = Calibration::TOUCH_SIZE_CALIBRATION_DEFAULT; >> String8 touchSizeCalibrationString; >> @@ -2294,10 +2308,47 @@ void TouchInputMapper::dispatchTouch(nsecs_t >> when, uint32_t policyFlags, >> uint32_t inIndex = touch->idToIndex[id]; >> >> const PointerData& in = touch->pointers[inIndex]; >> + float x,y; >> >> // X and Y >> - float x = float(in.x - mLocked.xOrigin) * mLocked.xScale; >> - float y = float(in.y - mLocked.yOrigin) * mLocked.yScale; >> + if ( mCalibration.havexscale && mCalibration.havexymix && >> + mCalibration.havexoffset && mCalibration.haveyxmix && >> + mCalibration.haveyscale && >> mCalibration.haveyoffset) { >> + >> + x = float(in.x - mLocked.xOrigin) * mLocked.xScale; >> + y = float(in.y - mLocked.yOrigin) * mLocked.yScale; >> + LOGI("x_orig = %f, y_orig = %f\n", x, y); >> + float x_temp = float(in.x - mLocked.xOrigin); >> + float y_temp = float(in.y - mLocked.yOrigin); >> + >> + //float xscale = 0.199488; >> + //float xymix = -0.000325; >> + //float xoffset = -6.898865; >> + //float yxmix = -0.000795; >> + //float yscale = 0.124000; >> + //float yoffset = -8.484802; >> + >> + // 5 point Calibration coefficients - from tsc.idc >> + float xscale = mCalibration.xscale; >> + float xymix = mCalibration.xymix; >> + float xoffset = mCalibration.xoffset; >> + float yxmix = mCalibration.yxmix; >> + float yscale = mCalibration.yscale; >> + float yoffset = mCalibration.yoffset; >> + >> + float x_after_calib = (xscale * x_temp) + (xymix * y_temp) + >> xoffset; >> + float y_after_calib = (yxmix * x_temp) + (yscale * y_temp) + >> yoffset; >> + >> + >> + LOGI("x_after_calib = %f, y_after_calib = %f\n xscale = %f, >> yoffset = %f\n", x_after_calib, y_after_calib, xscale, yoffset); >> + x = x_after_calib; >> + y = y_after_calib; >> + >> + } >> + else { >> + x = float(in.x - mLocked.xOrigin) * mLocked.xScale; >> + y = float(in.y - mLocked.yOrigin) * mLocked.yScale; >> + } >> >> // ToolMajor and ToolMinor >> float toolMajor, toolMinor; >> >> Touchscreen soft-keyboard inputs were being mis-reported on my WVGA >> screen and with the patch, keypresses are more accurate. >> >> Regards >> >> -- >> unsubscribe: [email protected] >> website: http://groups.google.com/group/android-porting >> > -- unsubscribe: [email protected] website: http://groups.google.com/group/android-porting
