| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

FrontPage

This version was saved 15 years, 7 months ago View current version     Page history
Saved by Matt
on September 9, 2008 at 10:30:18 pm
 

TouchShield data types and function wiki

This is a little wiki to describe all the major data types and functions that are available on the TouchShield (www.liquidware.com).

 

 

Data types

Point

This is the data type the TouchShield uses to provide x and y coordinates of a touchscreen press (like with a finger or stylus).

 

typedef struct Point

{

    unsigned char x; /*!< X coordinate, 8-bit */

    unsigned char y; /*!< X coordinate, 8-bit */

} POINT;

 

An example of using this in the Arduino code is:

 

POINT my_point; //defined anywhere in global memory space, or in loop, for instance

 

while (1) {

    if (touch_get_cursor(&my_point)) {

//touch_get_cursor stores the value of the touchscreen touch, and then you can read my_point.x and my_point.y below

     my_point.x; //x coordinates

     my_point.y; //y coordinates

     }

}

 

 

COLOR

This data type is how you define a color, which can then be used by a drawing function to make colored lines. It takes a standard RGB value, which can be hex or decimal, just as long as it's typed correctly, like the example below.

 

typedef struct Color

    {

    unsigned char red;

    unsigned char green;

    unsigned char blue;

    } COLOR;

 

An example of using this in the Arduino code is:

 

COLOR blue =  {40, 153, 224}; //each one is passed as Red, then Green, then Blue (hence RGB!)

COLOR red = {255, 0, 0};

COLOR black = {0, 0, 0};

COLOR white = {255, 255, 255};

COLOR gray = {200, 200, 200};

COLOR orange = {255, 153, 0};

COLOR green = {102, 153, 0};

COLOR dimred = {201, 84, 84};

 

lcd_line(8, 10, 50, 10, blue); //then you can use the colors in drawing functions

lcd_pixel(40, 40, red); //or pixel functions

 

 

 

 

 

 

 

 

 

Functions

char touch_get_cursor(POINT* p)

This function checks to see if a press has happened on the touchscreen, and if so, it stores the value of the x and y coordinates to a POINT variable. You have to pass the address of the POINT variable, by calling the function like this:

touch_get_cursor(&my_point)

 

 

An example of using this in the Arduino code is:

 

POINT my_point; //defined anywhere in global memory space, or in loop, for instance

 

while (1) {

    if (touch_get_cursor(&my_point)) {

//touch_get_cursor stores the value of the touchscreen touch, and then you can read my_point.x and my_point.y below

     my_point.x; //x coordinates

     my_point.y; //y coordinates

     }

}

 

 

 

 

   

 

 

 

 

 

 

 

Comments (0)

You don't have permission to comment on this page.