PV's Cassiopeia SDK A Simple Program /*********************************** * The following lines contain the header files that have to be included. ***********************************/ #include #include "define.h" #include "libc.h" #include "l_libc.h" /*********************************** * This line contains the name of the touch area/button. * You have to define each touch area like the following one. * I don't know what 0x9000 means but as you increase touch areas, these numbers have to inc too. Increase them in the followin manner. 0x9000 to 0x9009 then for more 0x900A - 0x900F then 0x9011 to 0x9019then 0x901A to 0x901F then 0x9021 to ox9029 and then 0x902A to 0x902F.. * Or you can use Menu Creator program to generate the code for your buttons. * We will use multiple touch areas in the second example. ************************************/ #define TouchAreaName1 0x9000 /*********************************** * The following lines contain function prototypes. ***********************************/ void Screen1text(); void OutputText(); /*********************************** * This line is very important and the block of statements following it. * It will contain all the information regarding all your touch areas on one particular screen. * For each screen in your programmes and all the touch buttons on it you have to create different TCHTBLs. * The touch table name I have used is TouchAreaScreen1Name. ***********************************/ TCHTBL far TouchAreaScreen1Name[] = { /*********************************** * The next 4 lines give the information(size, location and name) regarding the touch button on screen 1. * The four numbers in first line tell the position of the touch button on screen 1. * The first two numbers, 30 and 72 represent the position of the left top corner of the touch area. * The first one (30) is for the horzontal line of pixels. The second one is for the vertical ones. * The second pair(130, 80,) of numbers represent the right lower corner. * Here too the first is for the horizontal line of pixels and the second one for the vertical ones. * The easy way to remember this is to remember this formula. 1H-2V. * In a pair first(1 in 1H) number is to be counted horizontlly(H in 1H). * In a pair second(2 in 2V) number is to be counted vertically(V in 2V) * The PV screen is divided in 160 horizontal and 160 vertical pixels.(160x160) * I will give an example which will explain these numbers more clearly. * Lets say we have screen of resolution 20x20 pixels. * And on that I want to creat a button of 11, 8, 18, 10. * Top left corner is 11, 8, and the bottom right corner is 18, 10, 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 * * * * * * * * * * * * * * * * * * * * 2 1 * * * * * * * * * * * * * * * * * * * * 3 3 * * * * * * * * * * * * * * * * * * * * 4 5 * * * * * * * * * * * * * * * * * * * * 5 6 * * * * * * * * * * * * * * * * * * * * 6 7 * * * * * * * * * * * * * * * * * * * * 7 8 * * * * * * * * * * * |----------------| * 8 9 * * * * * * * * * * * |---Button------| * 9 10* * * * * * * * * * * |----------------| * 0 1 * * * * * * * * * * * * * * * * * * * * 1 2 * * * * * * * * * * * * * * * * * * * * 2 3 * * * * * * * * * * * * * * * * * * * * 3 4 * * * * * * * * * * * * * * * * * * * * 4 5 * * * * * * * * * * * * * * * * * * * * 5 6 * * * * * * * * * * * * * * * * * * * * 6 7 * * * * * * * * * * * * * * * * * * * * 7 8 * * * * * * * * * * * * * * * * * * * * 8 9 * * * * * * * * * * * * * * * * * * * * 9 20 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 * You can use PVScreener programme to decide where to place the boxes and the text. ***********************************/ 30, 72, 130, 88, ACT_MAKE | ACT_MOVE_IN | ACT_MOVE_OUT | ACT_BREAK_IN, TouchAreaName1,/*Name of a touch button*/ 0x0000, }; void Screen1text() { LibInitDisp(); /*********************************** * The following line clears the screen to display the new contents. * If not used, it will show the new content over the last screen. * In our case if the following line is not used the new button will be shown over the PV's main menu. * Remove it and recompile the code to see what I mean. Don't use it if you are creating a menu. ***********************************/ LibClrDisp(); LibGdsBox(30,72,130,88);/*Creats a box for the outline of the button.*/ LibPutProStr(IB_PFONT1,55,77,"Click Here!",50);/*Places the text Click Here! over and inside the box*/ LibPutDisp();/*Places the box and the text on the screen*/ } /*********************************** * The following line controls what happens when the button is tapped. * For each screen TCHTBL you create, you have to create a similar function. ***********************************/ void OutputText() { TCHSTS tsts; LibTchStackClr(); LibTchStackPush(NULL); LibTchStackPush(TchHardIcon); /*********************************** * The following line contains the name of the TCHTBL this function works with ***********************************/ LibTchStackPush(TouchAreaScreen1Name); LibTchInit(); LibRepOff(); LibTchWait(&tsts); /*********************************** * A switch statement is used and each case contains the name of a button in the screen whose TCHTBL name is given in the above lines. * In the LibTchStackPush() function. ***********************************/ switch(tsts.obj) { case TouchAreaName1 : /*Your code goes here*/ { LibClrDisp(); /*********************************** * The next three lines put text on the screen. * In each line there are two number before the text. Again 1H-2V. * The number after the text is the length of the text. ***********************************/ LibPutProStr(IB_PFONT1,41,66,"Congratulations!!",78); LibPutProStr(IB_PFONT1,37,75,"You have created",85); LibPutProStr(IB_PFONT1,25,84,"Your first PV program",110); LibPutDisp(); /* Puts the text on screen */ LibWait (IB_1SWAIT); /* This and the following four lines, each wait for 1 second*/ LibWait (IB_1SWAIT); LibWait (IB_1SWAIT); LibWait (IB_1SWAIT); LibWait (IB_1SWAIT); LibJumpMenu(); /*Exits back to the PV Menu*/ } } } void main() /*Your code goes here*/ { Screen1text(); OutputText(); }