; Screen coordinate utilities: position_aid and box_aid ; ; Version 2011 06 13 ; ; These two simple procedures may be downloaded alongside your display ; application to help you with positioning buttons, etc. on your display. ; ; If you want to find the pixel coordinates of a position on the display, ; or the pixel coordinates of a Box or TextBox then stop your application ; running (with Ctrl-C) and run either of the two lines below. ; ; position_aid(touch) ; ; box_aid(touch) ; ; (In VenomIDE you can just place the cursor on the line you want ; to run and hit 'F4') ; ; ; Note: These utilities assume that you have already set up ; and calibrated a TouchScreen object. See other code examples for how to ; do this, e.g. the GUI example project. ; ; You will have to replace the parameter 'touch' in the script lines ; above with the actual name of the TouchScreen object in your ; application. Use Ctrl-C to break out of these utilities. ; ; When you touch the screen the positions of your touches will be ; displayed on the terminal. Two touches are necessary for Each Box: two ; diagonally opposite corners of the box. ; You may find it useful to use a non-scratching stylus for the most ; accurate results. ; ; The code can be extended easily to actually draw boxes, etc, ; at the points that you touch. ;Position aid To position_aid(touch_object) Local x,y Print "Position aid. Touch the screen to see the position",CR Forever [ Await touch_object.Asserted ; wait for a touch x := touch_object.XPos y := touch_object.YPos PrintF("Pos %2i: (%3i,%3i)\n",Index,x,y) ;Simple debounce of 'no touch' Wait 100 Await touch_object.Asserted IsFalse Wait 100 ] End ;Box aid To box_aid(touch_object) Local x,y,last_x,last_y Print "Box aid. Touch the screen twice to see the Box parameters",CR Forever [ Await touch_object.Asserted x := touch_object.XPos y := touch_object.YPos PrintF("Box %2i: (%3i,%3i,",Index,x,y) Wait 100 Await touch_object.Asserted IsFalse Wait 100 Await touch_object.Asserted last_x := x last_y := y x := touch_object.XPos y := touch_object.YPos PrintF("%3i,%3i, border)\n",x-last_x,y-last_y) Wait 100 Await touch_object.Asserted IsFalse Wait 100 ] End