MityDSP Documentation Index
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
MityDSP::tcDspTouchScreen Class Reference

The tcDspTouchScreen class provides access to a 4-wire touch screen overlay device. More...

#include <core/DspTouchScreen.h>

List of all members.

Public Types

enum  teEventType { eeNoEvent, eePenDown, eeDataChange }

Public Member Functions

 tcDspTouchScreen (void *apAddress, unsigned int anScreenWidth, unsigned int anScreenHeight, SEM_Handle ahTouchSem=NULL, bool abRotate=false)
 This constructor is used to create an instance of the tcDspTouchScreen class.
 ~tcDspTouchScreen ()
 This destructor is used to close up and free tcDspTouchScreen resources.
bool IsTouched (void)
 This routine indicates whether or not the touch screen overlay is currently "touched".
void EventEnable (teEventType aeEvent)
 This routine enables posting of the user semaphore on pen down or data change events.
void Rotate (bool abRotate)
 Enables or disables 90 degree touch screen rotation.
bool IsRotated (void)
 Indicates whether touch screen is currently rotated 90 degrees.
bool GetPosition (tcDspDisplay::tsScreenCoords &arPos)
 This routine obtains the most recent touch screen controller ADC values, applies the current calibration, and returns the touch position in screen pixel coordinates (origin at upper left)
bool GetPositionRaw (tcDspDisplay::tsScreenCoords &arCounts)
 This routine reads the most recent touch screen controller ADC values.
void SetCalParams (tcDspDisplay::tsScreenCoords asCalUL, tcDspDisplay::tsScreenCoords asCalLR)
 This routine provides new calibration parameters to this instance of tcDspTouchScreen.
void GetCalParams (tcDspDisplay::tsScreenCoords &arCalUL, tcDspDisplay::tsScreenCoords &arCalLR)
 This routine returns the calibration parameters in use by this instance of tcDspTouchScreen.
bool CalUpperLeft (int anTimeoutMsec)
 This is a convenience routine to assist with calibration.
bool CalLowerRight (int anTimeoutMsec)
 This is a convenience routine to assist with calibration.
SEM_Handle GetTouchSem (void)
 Utility routine to get the active associated semaphore handle used for Touch notifications.
void SetTouchSem (SEM_Handle ahTouchSem)
 Utility routine to set the active associated semaphore handle used for Touch notifications.
void EnableGPIO (bool abEnable)
 Call this routine to enable continuous polling of the GPIO input data.
bool IsGPIOEnabled (void)
 Returns the enabled state from EnableGPIO().
void SetOutput (unsigned int anMask, unsigned int anValue)
 Set the output state of the GPIO pins attached to the display SPI controller.
unsigned int GetInputs (unsigned int anMask)
 Gets the most recently polled GPIO Input state from the GPIO devices attached to the display SPI controller.
int SendDispCommand (unsigned int anCommand, SEM_Handle ahDoneSem)
 Send an SPI Command to an attached display SPI controller.
unsigned int GetDispResponse (void)
 Retrieve response from an SPI Command issued to an attached display SPI controller.

Public Attributes

unsigned int mnInterruptCount
 ISR counter (debug).

Static Public Attributes

static const int gnMinAdcValue = 0
 minimum controller ADC value
static const int gnMaxAdcValue = 4095
 full-scale controller ADC value

Protected Member Functions

void TouchInterrupt (void)
 Interrupt service routine for the TouchScreen core.

Static Protected Member Functions

static int interrupt_dispatch (Arg arMyObject)
 Static interrupt dispatch routine.

Protected Attributes

LCK_Handle mhMutex
 Used to serialize access.
volatile unsigned int * mpBaseAddr
 TouchScreen base address.
unsigned short mnMyIntMask
 TouchScreen interrupt mask.
int mnMyIntLevel
 TouchScreen interrupt level.
int mnMyIntVector
 TouchScreen interrupt vector.
SEM_Handle mhTouchSemaphore
 Storage for touch/untouch semaphore.
SEM_Handle mhTmpTouch
 Temporarily take over "touched" semaphore.
int mnWidthPixels
 Pixel width of display.
int mnHeightPixels
 Pixel height of display.
bool mbRotate
 If true, X and Y axes are reversed.
tcDspDisplay::tsScreenCoords msCalUL
 Controller ADC values at screen upper left.
tcDspDisplay::tsScreenCoords msCalLR
 Controller ADC values at screen lower right.
teEventType meEvent
 Type of event to interrupt upon.
volatile SEM_Handle mhCommandDoneSem
 option semaphore to post when command is completed resp ready

Static Protected Attributes

static unsigned int mnTicksPerMsec = CLK_countspms() / CLK_getprd()
 Number of clocks per millisecond.

Detailed Description

The tcDspTouchScreen class provides access to a 4-wire touch screen overlay device.

A semaphore is posted every time the screen is touched. A pair of functions are provided to assist with calibration.

See also:
tcDspTouchScreen Page

Member Enumeration Documentation

Enumerator:
eeNoEvent 
eePenDown 
eeDataChange 

Constructor & Destructor Documentation

tcDspTouchScreen::tcDspTouchScreen ( void *  apAddress,
unsigned int  anScreenWidth,
unsigned int  anScreenHeight,
SEM_Handle  ahTouchSem = NULL,
bool  abRotate = false 
)

This constructor is used to create an instance of the tcDspTouchScreen class.

The address of the core, screen dimensions, and a semaphore handle (for screen touch and/or data change events) must be provided.

Parameters:
[in]apAddressBase Address of the Touch Screen controller core.
[in]anScreenWidthScreen width, in pixels.
[in]anScreenHeightScreen height, in pixels.
[in]ahTouchSemUser-semaphore to associate with screen events.
[in]abRotateSet to true to use a vertically oriented touch screen with a horizontally oriented display or vice versa.
Returns:
None.
See also:
DspTouchScreen.h
tcDspTouchScreen::~tcDspTouchScreen ( )

This destructor is used to close up and free tcDspTouchScreen resources.

Returns:
None.
See also:
DspTouchScreen.h

Member Function Documentation

bool tcDspTouchScreen::IsTouched ( void  )

This routine indicates whether or not the touch screen overlay is currently "touched".

Returns:
True if screen is currently "touched".
See also:
DspTouchScreen.h
void tcDspTouchScreen::EventEnable ( teEventType  aeEvent)

This routine enables posting of the user semaphore on pen down or data change events.

Parameters:
[in]aeEventType of event to set user semaphore upon:
  • eeNoEvent No events
  • eePenDown Whenever screen becomes "touched"
  • eeDataChange Whenever data changes
Returns:
None.
See also:
DspTouchScreen.h
void tcDspTouchScreen::Rotate ( bool  abRotate)

Enables or disables 90 degree touch screen rotation.

Note:
Touch screen must be recalibrated following a change in rotation.
Parameters:
[in]abRotateIf true, rotates screen coordinates 90-degrees.
Returns:
None.
See also:
DspTouchScreen.h
bool tcDspTouchScreen::IsRotated ( void  )

Indicates whether touch screen is currently rotated 90 degrees.

Returns:
True if rotated.
See also:
DspTouchScreen.h
bool tcDspTouchScreen::GetPosition ( tcDspDisplay::tsScreenCoords arPos)

This routine obtains the most recent touch screen controller ADC values, applies the current calibration, and returns the touch position in screen pixel coordinates (origin at upper left)

Parameters:
[out]arPosStorage for screen position results (pixels relative to upper left corner of display).
Returns:
True if successful.
See also:
DspTouchScreen.h
bool tcDspTouchScreen::GetPositionRaw ( tcDspDisplay::tsScreenCoords arCounts)

This routine reads the most recent touch screen controller ADC values.

Parameters:
[out]arCountsStorage for ADC count results (width and length axis values).
Returns:
True if screen is currently "touched".
See also:
DspTouchScreen.h
void tcDspTouchScreen::SetCalParams ( tcDspDisplay::tsScreenCoords  asCalUL,
tcDspDisplay::tsScreenCoords  asCalLR 
)

This routine provides new calibration parameters to this instance of tcDspTouchScreen.

This supports performing calibration manually, or restoring a previously-saved calibration.

Parameters:
[in]asCalULADC counts read at screen upper left corner.
[in]asCalLRADC counts read at screen lower right corner.
Returns:
None.
See also:
DspTouchScreen.h
void tcDspTouchScreen::GetCalParams ( tcDspDisplay::tsScreenCoords arCalUL,
tcDspDisplay::tsScreenCoords arCalLR 
)

This routine returns the calibration parameters in use by this instance of tcDspTouchScreen.

This supports saving off a calibration to be restored at a later time.

Parameters:
[out]arCalULADC counts read at screen upper left corner.
[out]arCalLRADC counts read at screen lower right corner.
Returns:
None.
See also:
DspTouchScreen.h
bool tcDspTouchScreen::CalUpperLeft ( int  anTimeoutMsec)

This is a convenience routine to assist with calibration.

After an application prompts its user to touch the upper left of the screen, this routine may be called to wait for the touch, read the ADC values, and update the current calibration.

Note:
Use tcDspTouchScreen::GetCalParams to retrieve results, if necessary.
Parameters:
[in]anTimeoutMsecHow long to wait for a touch (msec).
Returns:
True if successful within the timeout period.
See also:
DspTouchScreen.h
bool tcDspTouchScreen::CalLowerRight ( int  anTimeoutMsec)

This is a convenience routine to assist with calibration.

After an application prompts its user to touch the lower right of the screen, this routine may be called to wait for the touch, read the ADC values, and update the current calibration.

Note:
Use tcDspTouchScreen::GetCalParams to retrieve results, if necessary.
Parameters:
[in]anTimeoutMsecHow long to wait for a touch (msec).
Returns:
True if successful within the timeout period.
See also:
DspTouchScreen.h
SEM_Handle tcDspTouchScreen::GetTouchSem ( void  )

Utility routine to get the active associated semaphore handle used for Touch notifications.

Returns:
Active Semaphore Handle, (may be NULL if none set)
void tcDspTouchScreen::SetTouchSem ( SEM_Handle  ahTouchSem)

Utility routine to set the active associated semaphore handle used for Touch notifications.

This routine will override the last set (via the constructor, or this method) semaphore handle for the class.

Parameters:
ahTouchSemSemaphore Handle to use for notifications (may be NULL)
void tcDspTouchScreen::EnableGPIO ( bool  abEnable)

Call this routine to enable continuous polling of the GPIO input data.

Before calling EnableGPIO, you should at make one call to SetOutput() in order to ensure that the output state of the GPIO (if applicable) is in a known condition.

Note:
The GPIO routines are not specific to the ADS7843 touch controller wrapped by this class, but are specific to several Critical Link designed combined LCD / Touchscreen interfaces that provide additional SPI controlled I/O signals. This routine is not required if you are only integrating the touchscreen portion of the controller PCB.
Parameters:
abEnableWhen true start polling the I/O from the display SPI controller
bool tcDspTouchScreen::IsGPIOEnabled ( void  )

Returns the enabled state from EnableGPIO().

Returns:
true if GPIO polling from the display SPI controller is enabled
void tcDspTouchScreen::SetOutput ( unsigned int  anMask,
unsigned int  anValue 
)

Set the output state of the GPIO pins attached to the display SPI controller.

You must call EnableGPIO before the outputs are sent to the controller.

Note:
The GPIO routines are not specific to the ADS7843 touch controller wrapped by this class, but are specific to several Critical Link designed combined LCD / Touchscreen interfaces that provide additional SPI controlled I/O signals. This routine is not required if you are only integrating the touchscreen portion of the controller PCB.
Parameters:
anMaska bitmask (24 bits) representing the I/O lines to alter
anValuethe value for the bits in anMask to change
unsigned int tcDspTouchScreen::GetInputs ( unsigned int  anMask)

Gets the most recently polled GPIO Input state from the GPIO devices attached to the display SPI controller.

You must call EnableGPIO before the inputs are read back by the controller.

Note:
The GPIO routines are not specific to the ADS7843 touch controller wrapped by this class, but are specific to several Critical Link designed combined LCD / Touchscreen interfaces that provide additional SPI controlled I/O signals. This routine is not required if you are only integrating the touchscreen portion of the controller PCB.
Parameters:
anMaska bitmask (24 bits) representing the I/O lines to read
Returns:
the value for the bits in anMask read by the controller
int tcDspTouchScreen::SendDispCommand ( unsigned int  anCommand,
SEM_Handle  ahDoneSem 
)

Send an SPI Command to an attached display SPI controller.

Note:
The SendDispCommand and GetDispResponse routines are not specific to the ADS7843 touch controller wrapped by this class, but are specific to several Critical Link designed combined LCD / Touchscreen interfaces that provide additional SPI controlled I/O signals. This routine is not required if you are only integrating the touchscreen portion of the controller PCB.
Parameters:
anCommand24 bit command to send to the controller
ahDoneSemSemaphore handle (may be NULL) to post when command/response cycle is complete.
Returns:
zero on success, -1 if device is busy
unsigned int tcDspTouchScreen::GetDispResponse ( void  )

Retrieve response from an SPI Command issued to an attached display SPI controller.

This is typically called after a SEM_pend() is called on the SEM_Handle ahDoneSem passed into the SendDispCommand method.

Note:
The SendDispCommand and GetDispResponse routines are not specific to the ADS7843 touch controller wrapped by this class, but are specific to several Critical Link designed combined LCD / Touchscreen interfaces that provide additional SPI controlled I/O signals. This routine is not required if you are only integrating the touchscreen portion of the controller PCB.
Returns:
the 24 bit mask of the response to the command
int tcDspTouchScreen::interrupt_dispatch ( Arg  ahMyObject)
staticprotected

Static interrupt dispatch routine.

Required because of the hidden this pointer associated with a member function, which cannot be passed directly to the interrupt dispatcher.

Parameters:
ahMyObjectThe "this->" pointer for the instance of tcDspTouchScreen associated with this ISR.
Returns:
0
void tcDspTouchScreen::TouchInterrupt ( void  )
protected

Interrupt service routine for the TouchScreen core.

The ISR reads and clears a pending screen touch interrupt. If a semaphore is associated with the event, the ISR increments the semaphore value.

Note:
"Interrupt-ness" is taken care of by the 'dispatcher' in DSP/BIOS. Installed by the constructor.
Returns:
None.

Member Data Documentation

unsigned int MityDSP::tcDspTouchScreen::mnInterruptCount

ISR counter (debug).

const int MityDSP::tcDspTouchScreen::gnMinAdcValue = 0
static

minimum controller ADC value

const int MityDSP::tcDspTouchScreen::gnMaxAdcValue = 4095
static

full-scale controller ADC value

unsigned int tcDspTouchScreen::mnTicksPerMsec = CLK_countspms() / CLK_getprd()
staticprotected

Number of clocks per millisecond.

LCK_Handle MityDSP::tcDspTouchScreen::mhMutex
protected

Used to serialize access.

volatile unsigned int* MityDSP::tcDspTouchScreen::mpBaseAddr
protected

TouchScreen base address.

unsigned short MityDSP::tcDspTouchScreen::mnMyIntMask
protected

TouchScreen interrupt mask.

int MityDSP::tcDspTouchScreen::mnMyIntLevel
protected

TouchScreen interrupt level.

int MityDSP::tcDspTouchScreen::mnMyIntVector
protected

TouchScreen interrupt vector.

SEM_Handle MityDSP::tcDspTouchScreen::mhTouchSemaphore
protected

Storage for touch/untouch semaphore.

SEM_Handle MityDSP::tcDspTouchScreen::mhTmpTouch
protected

Temporarily take over "touched" semaphore.

int MityDSP::tcDspTouchScreen::mnWidthPixels
protected

Pixel width of display.

int MityDSP::tcDspTouchScreen::mnHeightPixels
protected

Pixel height of display.

bool MityDSP::tcDspTouchScreen::mbRotate
protected

If true, X and Y axes are reversed.

tcDspDisplay::tsScreenCoords MityDSP::tcDspTouchScreen::msCalUL
protected

Controller ADC values at screen upper left.

tcDspDisplay::tsScreenCoords MityDSP::tcDspTouchScreen::msCalLR
protected

Controller ADC values at screen lower right.

teEventType MityDSP::tcDspTouchScreen::meEvent
protected

Type of event to interrupt upon.

volatile SEM_Handle MityDSP::tcDspTouchScreen::mhCommandDoneSem
protected

option semaphore to post when command is completed resp ready


  
Generated on Mon Apr 22 2013 11:33:05 for MityDSP Core by  Doxygen Version 1.8.1.1
Copyright © 2009, Critical Link LLC, All rights reserved.