The tcDspTouchScreen class provides access to a 4-wire touch screen overlay device. More...
#include <core/DspTouchScreen.h>
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. |
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.
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.
[in] | apAddress | Base Address of the Touch Screen controller core. |
[in] | anScreenWidth | Screen width, in pixels. |
[in] | anScreenHeight | Screen height, in pixels. |
[in] | ahTouchSem | User-semaphore to associate with screen events. |
[in] | abRotate | Set to true to use a vertically oriented touch screen with a horizontally oriented display or vice versa. |
tcDspTouchScreen::~tcDspTouchScreen | ( | ) |
This destructor is used to close up and free tcDspTouchScreen resources.
bool tcDspTouchScreen::IsTouched | ( | void | ) |
This routine indicates whether or not the touch screen overlay is currently "touched".
void tcDspTouchScreen::EventEnable | ( | teEventType | aeEvent | ) |
This routine enables posting of the user semaphore on pen down or data change events.
[in] | aeEvent | Type of event to set user semaphore upon:
|
void tcDspTouchScreen::Rotate | ( | bool | abRotate | ) |
Enables or disables 90 degree touch screen rotation.
[in] | abRotate | If true, rotates screen coordinates 90-degrees. |
bool tcDspTouchScreen::IsRotated | ( | void | ) |
Indicates whether touch screen is currently rotated 90 degrees.
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).
[out] | arPos | Storage for screen position results (pixels relative to upper left corner of display). |
bool tcDspTouchScreen::GetPositionRaw | ( | tcDspDisplay::tsScreenCoords & | arCounts | ) |
This routine reads the most recent touch screen controller ADC values.
[out] | arCounts | Storage for ADC count results (width and length axis values). |
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.
[in] | asCalUL | ADC counts read at screen upper left corner. |
[in] | asCalLR | ADC counts read at screen lower right corner. |
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.
[out] | arCalUL | ADC counts read at screen upper left corner. |
[out] | arCalLR | ADC counts read at screen lower right corner. |
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.
[in] | anTimeoutMsec | How long to wait for a touch (msec). |
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.
[in] | anTimeoutMsec | How long to wait for a touch (msec). |
SEM_Handle tcDspTouchScreen::GetTouchSem | ( | void | ) |
Utility routine to get the active associated semaphore handle used for Touch notifications.
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.
ahTouchSem | Semaphore 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.
abEnable | When true start polling the I/O from the display SPI controller |
bool tcDspTouchScreen::IsGPIOEnabled | ( | void | ) |
Returns the enabled state from EnableGPIO().
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.
anMask | a bitmask (24 bits) representing the I/O lines to alter | |
anValue | the 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.
anMask | a bitmask (24 bits) representing the I/O lines to read |
int tcDspTouchScreen::SendDispCommand | ( | unsigned int | anCommand, | |
SEM_Handle | ahDoneSem | |||
) |
Send an SPI Command to an attached display SPI controller.
anCommand | 24 bit command to send to the controller | |
ahDoneSem | Semaphore handle (may be NULL) to post when command/response cycle is complete. |
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.
int tcDspTouchScreen::interrupt_dispatch | ( | Arg | ahMyObject | ) | [static, protected] |
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.
ahMyObject | The "this->" pointer for the instance of tcDspTouchScreen associated with this ISR. |
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.
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() [static, protected] |
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.
Controller ADC values at screen upper left.
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