HP Forums

Full Version: Testing the touch screen
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Just a little noddy I wrote to view output from the mouse() command. Interesting to see how it handles two fingers, stretch (type 3) and has obvious issues with 'rotate' detection (type 4).

Other calculators I've used in the past have a function to fill a string with your chosen character. Can't seem to find it on the prime, hence the huge string on line 4...Anyone know of such a command ?

Regards

Code:

EXPORT Touchscreen()
 
BEGIN
LOCAL TOUCH,ST;
"                                                                                                    "▶ST;

RECT_P();      //CLEAR SCREEN
TEXTOUT_P("TOUCH(1)=",0,0,0,#00FF00,300,0);
TEXTOUT_P("TOUCH(2)=",0,32,0,#00FF00,300,0);
TEXTOUT_P("Touch/Drag With One Or Two Fingers",0,90,0,#0000FF,300,0);
TEXTOUT_P("ESC to exit",0,106,0,#0000FF,300,0);

repeat       //CLEAR TOUCH BUFFER
 TOUCH:=mouse();
until size(TOUCH(1))=0;
 
WHILE ISKEYDOWN(4)<>1 do    //ESC KEY ?
 TOUCH:=mouse();
 WAIT(0.1);
 TEXTOUT_P(ST,0,18,2,#00FF00,300,0);
 TEXTOUT_P(TOUCH(1),0,18,2,#00FF00,300,0);
 TEXTOUT_P(ST,0,50,2,#00FF00,300,0);
 TEXTOUT_P(TOUCH(2),0,50,2,#00FF00,300,0);

// Example of obtaining decimal coordinates
//   if size(TOUCH(1)) then
//     if  TOUCH(1,5)==0 then
//        X:=B→R(TOUCH(1,1));
//        Y:=B→R(TOUCH(1,2));
//     END;
//   END;

 END;
END;
(05-24-2015 07:55 AM)Digitaldreams Wrote: [ -> ]...
Note the fifth line that contains "▶ST.....in between the quotes there should be around 94 spaces. I see them when editing the post but not when viewing ??. This forum seems to strip out additional spaces !?. ...

The missing spaces should be visible, if you're entering the code between the code tags.
Code:
[code ] your code [/code ]
Code:
EXPORT Touchscreen()

BEGIN
  LOCAL TOUCH,ST;
  "                                                                                                    "▶ST;

  RECT_P();      //CLEAR SCREEN 
  TEXTOUT_P("TOUCH(1)=",0,0,0,#00FF00,300,0);
  TEXTOUT_P("TOUCH(2)=",0,32,0,#00FF00,300,0);
  TEXTOUT_P("Touch/Drag With One Or Two Fingers",0,90,0,#0000FF,300,0);
  TEXTOUT_P("ESC to exit",0,106,0,#0000FF,300,0);
  
  repeat       //CLEAR TOUCH BUFF
    TOUCH:=mouse();
  until size(TOUCH(1))=0;

  WHILE ISKEYDOWN(4)<>1 do    //ESC KEY ?
    TOUCH:=mouse();
    WAIT(0.1);
    TEXTOUT_P(ST,0,18,2,#00FF00,300,0);
    TEXTOUT_P(TOUCH(1),0,18,2,#00FF00,300,0);
    TEXTOUT_P(ST,0,50,2,#00FF00,300,0);
    TEXTOUT_P(TOUCH(2),0,50,2,#00FF00,300,0);
    
    // Example of obtaining decimal coordinates
    //   if size(TOUCH(1)) then
    //     if  TOUCH(1,5)==0 then
    //        X:=B→R(TOUCH(1,1));
    //        Y:=B→R(TOUCH(1,2));
    //     END;
    //   END;

  END;
END;
Thanks Thomas.

Post updated. Part of my problem is viewing posts with Android, they look a mess..
(05-24-2015 07:55 AM)Digitaldreams Wrote: [ -> ]Other calculators I've used in the past have a function to fill a string with your chosen character. Can't seem to find it on the prime, hence the huge string on line 4...Anyone know of such a command ?

To create a string with 94 spaces you can do:

Code:
CHAR(MAKELIST(32,A,1,94))▶ST;

There may be other ways to do it.
(05-24-2015 10:42 AM)Didier Lachieze Wrote: [ -> ]To create a string with 94 spaces you can do:

Code:
CHAR(MAKELIST(32,A,1,94))▶ST;

There may be other ways to do it.

replace("",94," ") is fast and easy.
(05-24-2015 10:54 AM)Joe Horn Wrote: [ -> ]replace("",94," ") is fast and easy.
Nice trick but it works only for a string of spaces.
Reference URL's