/* Converts the supplied touch screen location (screenPtr) to a pixel location on the display (displayPtr) using the supplied matrix. The screen orientation is also taken into account when converting the touch screen co-ordinate to a pixel location on the LCD.  */
int getDisplayPoint(tsPoint_t *displayPtr, tsPoint_t *screenPtr, tsMatrix_t *matrixPtr)
/* Converts the supplied touch screen location (screenPtr) to a pixel location on the display (displayPtr) using the supplied matrix. The screen orientation is also taken into account when converting the touch screen co-ordinate to a pixel location on the LCD.  */
int getDisplayPoint(tsPoint_t *displayPtr, tsPoint_t *screenPtr, tsMatrix_t *matrixPtr)
{
  int  retValue = TS_ERROR_NONE ;
  if( matrixPtr->Divider != 0 )
  {
    displayPtr->x = ( (matrixPtr->An * screenPtr->x) + 
                      (matrixPtr->Bn * screenPtr->y) + 
                       matrixPtr->Cn 
                    ) / matrixPtr->Divider ;
    displayPtr->y = ( (matrixPtr->Dn * screenPtr->x) + 
                      (matrixPtr->En * screenPtr->y) + 
                       matrixPtr->Fn 
                    ) / matrixPtr->Divider ;
  }
  else
  {
    return -1;
  }
  lcdOrientation_t orientation;
  orientation = lcdGetOrientation();
  if (orientation == LCD_ORIENTATION_LANDSCAPE)
  {
      uint32_t oldx, oldy;
      oldx = displayPtr->x;
      oldy = displayPtr->y;
      displayPtr->x = oldy;
      displayPtr->y = lcdGetHeight() - oldx;
  }
  return( retValue ) ;
}