23.11.2012 Views

2 Visual Components Manuals

2 Visual Components Manuals

2 Visual Components Manuals

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Introduction to <strong>Visual</strong> <strong>Components</strong> 2.3<br />

The fixed position of the HotSpot in the key grid is assigned in the dialog box. This allows the old key matrix to<br />

be reestablished.<br />

This method is somewhat elaborate and is only meant as a transition.<br />

In the long term, the project should be changed to use button and HotSpot technology.<br />

4.14.2.2 Calculating the Key Matrix<br />

Another possibility exists to convert old matrix information by reading the matrix position using the VISAPI. The<br />

VA_GetTouchAction() function from the VISAPI Library<br />

The following is an excerpt of code for converting the key matrix for a VGA display. This only applies for a VGA<br />

display. For 1/4 VGA, calculation takes place using lines and columns.<br />

#include<br />

#include #include "visapi.h" #define T_SIZE 192 /* VGA 40x40 pixel array<br />

from 640x480*/ UINT _LOCAL ready; TouchAction _GLOBAL touch; UDINT _GLOBAL x_position; UDINT<br />

_GLOBAL y_position; USINT _GLOBAL touch_status; _GLOBAL unsigned char KeyMatrix[T_SIZE]; _GLOBAL<br />

unsigned long VC_HANDLE; _CYCLIC void Cyclic(void) { int lines; int columns; int offset; if (!ready) {<br />

VC_HANDLE = VA_Setup(1 , "display"); /* VC project name */ if (VC_HANDLE) ready = 1; } if (ready) {<br />

if (!VA_Saccess(1,VC_HANDLE)) { VA_GetTouchAction (1,VC_HANDLE,&touch); VA_Srelease(1,VC_HANDLE);<br />

x_position = touch.x + 1; y_position = touch.y + 1; touch_status = touch.status; if(touch_status ==<br />

2) /* Nothing pressed */ memset(KeyMatrix,0,T_SIZE); else { /* Columns */ columns = (x_position /<br />

40); /* Lines */ lines = (y_position / 40); offset = (columns + (lines*16)); /* Since 16 columns per<br />

line (640/40)*/ if(offset < T_SIZE) KeyMatrix[offset] = 1; /* Current touch field */ else<br />

memset(KeyMatrix,0,T_SIZE); /* Error */ } } } }<br />

Tip:<br />

This new VISAPI function permits an exact pixel evaluation of the pressed coordinates.<br />

4.14.2.2 Calculating the Key Matrix 447

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!