KSM edits to RA8875
Diff: RA8875_Touch.cpp
- Revision:
- 167:8aa3fb2a5a31
- Parent:
- 166:53fd4a876dac
- Child:
- 168:37a0c4d8791c
--- a/RA8875_Touch.cpp Sun Feb 24 19:28:26 2019 +0000 +++ b/RA8875_Touch.cpp Tue Feb 26 19:52:57 2019 +0000 @@ -53,7 +53,7 @@ panelTouched = false; if (useTouchPanel == TP_GSL1680) { INFO("TouchPanelInit: TP_GSL1680"); - /// @TODO Added support for TP_GSL1680 + /// @todo Added support for TP_GSL1680 } else if (useTouchPanel == TP_FT5206) { // Set to normal mode INFO("TouchPanelInit: TP_FT5206"); @@ -87,7 +87,7 @@ { if (useTouchPanel == TP_GSL1680) { INFO("TouchPanelInit: TP_GSL1680"); - /// @TODO Added support for TP_GSL1680 + /// @todo Added support for TP_GSL1680 } else if (useTouchPanel == TP_FT5206) { INFO("TouchPanelInit: TP_FT5206"); TouchPanelInit(); @@ -536,168 +536,168 @@ return ret; } -/* The following section is derived from Carlos E. Vidales. - * - * Copyright (c) 2001, Carlos E. Vidales. All rights reserved. - * - * This sample program was written and put in the public domain - * by Carlos E. Vidales. The program is provided "as is" - * without warranty of any kind, either expressed or implied. - * If you choose to use the program within your own products - * you do so at your own risk, and assume the responsibility - * for servicing, repairing or correcting the program should - * it prove defective in any manner. - * You may copy and distribute the program's source code in any - * medium, provided that you also include in each copy an - * appropriate copyright notice and disclaimer of warranty. - * You may also modify this program and distribute copies of - * it provided that you include prominent notices stating - * that you changed the file(s) and the date of any change, - * and that you do not charge any royalties or licenses for - * its use. - * - * This file contains functions that implement calculations - * necessary to obtain calibration factors for a touch screen - * that suffers from multiple distortion effects: namely, - * translation, scaling and rotation. - * - * The following set of equations represent a valid display - * point given a corresponding set of touch screen points: - * - * /- -\ - * /- -\ /- -\ | | - * | | | | | Xs | - * | Xd | | A B C | | | - * | | = | | * | Ys | - * | Yd | | D E F | | | - * | | | | | 1 | - * \- -/ \- -/ | | - * \- -/ - * where: - * (Xd,Yd) represents the desired display point - * coordinates, - * (Xs,Ys) represents the available touch screen - * coordinates, and the matrix - * /- -\ - * |A,B,C| - * |D,E,F| represents the factors used to translate - * \- -/ the available touch screen point values - * into the corresponding display - * coordinates. - * Note that for practical considerations, the utilities - * within this file do not use the matrix coefficients as - * defined above, but instead use the following - * equivalents, since floating point math is not used: - * A = An/Divider - * B = Bn/Divider - * C = Cn/Divider - * D = Dn/Divider - * E = En/Divider - * F = Fn/Divider - * The functions provided within this file are: - * setCalibrationMatrix() - calculates the set of factors - * in the above equation, given - * three sets of test points. - * getDisplayPoint() - returns the actual display - * coordinates, given a set of - * touch screen coordinates. - * translateRawScreenCoordinates() - helper function to transform - * raw screen points into values - * scaled to the desired display - * resolution. - */ - -/********************************************************************** - * - * Function: setCalibrationMatrix() - * - * Description: Calling this function with valid input data - * in the display and screen input arguments - * causes the calibration factors between the - * screen and display points to be calculated, - * and the output argument - matrixPtr - to be - * populated. - * - * This function needs to be called only when new - * calibration factors are desired. - * - * - * Argument(s): displayPtr (input) - Pointer to an array of three - * sample, reference points. - * screenPtr (input) - Pointer to the array of touch - * screen points corresponding - * to the reference display points. - * matrixPtr (output) - Pointer to the calibration - * matrix computed for the set - * of points being provided. - * - * - * From the article text, recall that the matrix coefficients are - * resolved to be the following: - * - * - * Divider = (Xs0 - Xs2)*(Ys1 - Ys2) - (Xs1 - Xs2)*(Ys0 - Ys2) - * - * - * - * (Xd0 - Xd2)*(Ys1 - Ys2) - (Xd1 - Xd2)*(Ys0 - Ys2) - * A = --------------------------------------------------- - * Divider - * - * - * (Xs0 - Xs2)*(Xd1 - Xd2) - (Xd0 - Xd2)*(Xs1 - Xs2) - * B = --------------------------------------------------- - * Divider - * - * - * Ys0*(Xs2*Xd1 - Xs1*Xd2) + - * Ys1*(Xs0*Xd2 - Xs2*Xd0) + - * Ys2*(Xs1*Xd0 - Xs0*Xd1) - * C = --------------------------------------------------- - * Divider - * - * - * (Yd0 - Yd2)*(Ys1 - Ys2) - (Yd1 - Yd2)*(Ys0 - Ys2) - * D = --------------------------------------------------- - * Divider - * - * - * (Xs0 - Xs2)*(Yd1 - Yd2) - (Yd0 - Yd2)*(Xs1 - Xs2) - * E = --------------------------------------------------- - * Divider - * - * - * Ys0*(Xs2*Yd1 - Xs1*Yd2) + - * Ys1*(Xs0*Yd2 - Xs2*Yd0) + - * Ys2*(Xs1*Yd0 - Xs0*Yd1) - * F = --------------------------------------------------- - * Divider - * - * - * Return: OK - the calibration matrix was correctly - * calculated and its value is in the - * output argument. - * NOT_OK - an error was detected and the - * function failed to return a valid - * set of matrix values. - * The only time this sample code returns - * NOT_OK is when Divider == 0 - * - * - * - * NOTE! NOTE! NOTE! - * - * setCalibrationMatrix() and getDisplayPoint() will do fine - * for you as they are, provided that your digitizer - * resolution does not exceed 10 bits (1024 values). Higher - * resolutions may cause the integer operations to overflow - * and return incorrect values. If you wish to use these - * functions with digitizer resolutions of 12 bits (4096 - * values) you will either have to a) use 64-bit signed - * integer variables and math, or b) judiciously modify the - * operations to scale results by a factor of 2 or even 4. - * - */ +/// The following section is derived from Carlos E. Vidales. +/// +/// @copyright © 2001, Carlos E. Vidales. All rights reserved. +/// +/// This sample program was written and put in the public domain +/// by Carlos E. Vidales. The program is provided "as is" +/// without warranty of any kind, either expressed or implied. +/// If you choose to use the program within your own products +/// you do so at your own risk, and assume the responsibility +/// for servicing, repairing or correcting the program should +/// it prove defective in any manner. +/// You may copy and distribute the program's source code in any +/// medium, provided that you also include in each copy an +/// appropriate copyright notice and disclaimer of warranty. +/// You may also modify this program and distribute copies of +/// it provided that you include prominent notices stating +/// that you changed the file(s) and the date of any change, +/// and that you do not charge any royalties or licenses for +/// its use. +/// +/// This file contains functions that implement calculations +/// necessary to obtain calibration factors for a touch screen +/// that suffers from multiple distortion effects: namely, +/// translation, scaling and rotation. +/// +/// The following set of equations represent a valid display +/// point given a corresponding set of touch screen points: +/// +/// <pre> +/// /- -\ +/// /- -\ /- -\ | | +/// | | | | | Xs | +/// | Xd | | A B C | | | +/// | | = | | * | Ys | +/// | Yd | | D E F | | | +/// | | | | | 1 | +/// \- -/ \- -/ | | +/// \- -/ +/// where: +/// (Xd,Yd) represents the desired display point +/// coordinates, +/// (Xs,Ys) represents the available touch screen +/// coordinates, and the matrix +/// /- -\ +/// |A,B,C| +/// |D,E,F| represents the factors used to translate +/// \- -/ the available touch screen point values +/// into the corresponding display +/// coordinates. +/// Note that for practical considerations, the utilities +/// within this file do not use the matrix coefficients as +/// defined above, but instead use the following +/// equivalents, since floating point math is not used: +/// A = An/Divider +/// B = Bn/Divider +/// C = Cn/Divider +/// D = Dn/Divider +/// E = En/Divider +/// F = Fn/Divider +/// The functions provided within this file are: +/// setCalibrationMatrix() - calculates the set of factors +/// in the above equation, given +/// three sets of test points. +/// getDisplayPoint() - returns the actual display +/// coordinates, given a set of +/// touch screen coordinates. +/// translateRawScreenCoordinates() - helper function to transform +/// raw screen points into values +/// scaled to the desired display +/// resolution. +/// +/// +/// Function: setCalibrationMatrix() +/// +/// Description: Calling this function with valid input data +/// in the display and screen input arguments +/// causes the calibration factors between the +/// screen and display points to be calculated, +/// and the output argument - matrixPtr - to be +/// populated. +/// +/// This function needs to be called only when new +/// calibration factors are desired. +/// +/// +/// Argument(s): displayPtr (input) - Pointer to an array of three +/// sample, reference points. +/// screenPtr (input) - Pointer to the array of touch +/// screen points corresponding +/// to the reference display points. +/// matrixPtr (output) - Pointer to the calibration +/// matrix computed for the set +/// of points being provided. +/// +/// +/// From the article text, recall that the matrix coefficients are +/// resolved to be the following: +/// +/// +/// Divider = (Xs0 - Xs2)*(Ys1 - Ys2) - (Xs1 - Xs2)*(Ys0 - Ys2) +/// +/// +/// +/// (Xd0 - Xd2)*(Ys1 - Ys2) - (Xd1 - Xd2)*(Ys0 - Ys2) +/// A = --------------------------------------------------- +/// Divider +/// +/// +/// (Xs0 - Xs2)*(Xd1 - Xd2) - (Xd0 - Xd2)*(Xs1 - Xs2) +/// B = --------------------------------------------------- +/// Divider +/// +/// +/// Ys0*(Xs2*Xd1 - Xs1*Xd2) + +/// Ys1*(Xs0*Xd2 - Xs2*Xd0) + +/// Ys2*(Xs1*Xd0 - Xs0*Xd1) +/// C = --------------------------------------------------- +/// Divider +/// +/// +/// (Yd0 - Yd2)*(Ys1 - Ys2) - (Yd1 - Yd2)*(Ys0 - Ys2) +/// D = --------------------------------------------------- +/// Divider +/// +/// +/// (Xs0 - Xs2)*(Yd1 - Yd2) - (Yd0 - Yd2)*(Xs1 - Xs2) +/// E = --------------------------------------------------- +/// Divider +/// +/// +/// Ys0*(Xs2*Yd1 - Xs1*Yd2) + +/// Ys1*(Xs0*Yd2 - Xs2*Yd0) + +/// Ys2*(Xs1*Yd0 - Xs0*Yd1) +/// F = --------------------------------------------------- +/// Divider +/// +/// +/// Return: OK - the calibration matrix was correctly +/// calculated and its value is in the +/// output argument. +/// NOT_OK - an error was detected and the +/// function failed to return a valid +/// set of matrix values. +/// The only time this sample code returns +/// NOT_OK is when Divider == 0 +/// +/// +/// +/// NOTE! NOTE! NOTE! +/// +/// setCalibrationMatrix() and getDisplayPoint() will do fine +/// for you as they are, provided that your digitizer +/// resolution does not exceed 10 bits (1024 values). Higher +/// resolutions may cause the integer operations to overflow +/// and return incorrect values. If you wish to use these +/// functions with digitizer resolutions of 12 bits (4096 +/// values) you will either have to a) use 64-bit signed +/// integer variables and math, or b) judiciously modify the +/// operations to scale results by a factor of 2 or even 4. +/// +/// </pre> +/// RetCode_t RA8875::TouchPanelComputeCalibration(point_t * displayPtr, point_t * screenPtr, tpMatrix_t * matrixPtr) { RetCode_t retValue = noerror;