Post Reply 
WAIT, PRINT and timeout
07-18-2015, 11:22 AM
Post: #1
WAIT, PRINT and timeout
hi,
to display more pages with Terminal I put inside a printing series this:
Code:

// other print("something "); series
WAIT();
PRINT();
// again print("something else "); series
that command waits, then clears Terminal and prints another page.
But if the user does nothing, after a few seconds it loads the next page and doesn't let the time to read the previous one...
I need a hint to wait without timeout.
Any help?

thanks in advance!

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
07-18-2015, 11:35 AM (This post was last modified: 07-18-2015 11:40 AM by Thomas_Sch.)
Post: #2
RE: WAIT, PRINT and timeout
(07-18-2015 11:22 AM)salvomic Wrote:  hi,
to display more pages with Terminal I put inside a printing series this:
Code:

// other print("something "); series
WAIT();
PRINT();
// again print("something else "); series
that command waits, then clears Terminal and prints another page.
But if the user does nothing, after a few seconds it loads the next page and doesn't let the time to read the previous one...
I need a hint to wait without timeout.
Any help?

thanks in advance!

Salvo
Hi Salvo,
please try to use the parameter -1 for wait,
WAIT(-1);

Help says:
"If n = -1:
Execution paused until a key is pressed or there is a mouse event. "

EDIT:
sorry, this seems also be limited to 1 minute (".. After a 1 minute timeout, returns -1")
You could try to catch the return value of wait89, and stay in a loop,
until the value is not equal to -1.
Find all posts by this user
Quote this message in a reply
07-18-2015, 12:32 PM
Post: #3
RE: WAIT, PRINT and timeout
Salvo,

This seems to do everything you need:

Code:

EXPORT eraseme()
BEGIN
 A:=−1;
 PRINT();
 PRINT(1);
 WHILE A<0 DO
  A:=WAIT();
  IF TYPE(A)==DOM_INT THEN ELSE BREAK;END;
 END;
 PRINT();
 PRINT(2);
END;

It waits for a screen tap or key hit then continues. The problem is that the screen dims after about 10 seconds. Do you know of a way to set that to a longer time?

Road
Find all posts by this user
Quote this message in a reply
07-18-2015, 12:33 PM
Post: #4
RE: WAIT, PRINT and timeout
Salvo,

This seems to do everything you need:

Code:

EXPORT eraseme()
BEGIN
 A:=−1;
 PRINT();
 PRINT(1);
 WHILE A<0 DO
  A:=WAIT();
  IF TYPE(A)==DOM_INT THEN ELSE BREAK;END;
 END;
 PRINT();
 PRINT(2);
END;

It waits for a screen tap or key hit then continues. The problem is that the screen dims after about 10 seconds. Do you know of a way to set that to a longer time?

Road
Find all posts by this user
Quote this message in a reply
07-18-2015, 12:44 PM (This post was last modified: 07-18-2015 12:48 PM by salvomic.)
Post: #5
RE: WAIT, PRINT and timeout
(07-18-2015 11:35 AM)Thomas_Sch Wrote:  ...
please try to use the parameter -1 for wait,
WAIT(-1);

Help says:
"If n = -1:
Execution paused until a key is pressed or there is a mouse event. "

EDIT:
sorry, this seems also be limited to 1 minute ...

(07-18-2015 12:32 PM)roadrunner Wrote:  Salvo,

This seems to do everything you need:

...
It waits for a screen tap or key hit then continues. The problem is that the screen dims after about 10 seconds. Do you know of a way to set that to a longer time?

Road

hi Road and Thomas,
if there is a standard timeout of 1min, I could try to use
WAIT(120); or WAIT(240);
to get 2min or 4min, for example...

But, what's the real difference between
WAIT(0), WAIT() and WAIT(-1),
if they timeout both after 1min?

In my case the ideal condition could be:
timeout 2-3 minutes if the user don't make anything, or next page if the user press Enter.
In my program (I don't know how correct it) if the user tap on the screen Terminal goes to the last page and not in those in the middle: idea?

Salvo

EDIT:
WAIT(120); isn't good: it waits 120 seconds without let use key or Enter...

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
07-18-2015, 04:08 PM
Post: #6
RE: WAIT, PRINT and timeout
Hi Salvo,

I see what you mean. There appears to be no way to set the time out to more than a minute and wait for a key press at the same time.

I did come up with this code that won't skip the second page if you tap the screen, but if you accidently drag your finger on the screen it does skip the second page.

Code:

local waittap()
BEGIN
 LOCAL a;
 a:=1;
 WHILE a>0 DO
  a:=−WAIT(−1);
  IF TYPE(a)==6 THEN
   wait(-1);
   wait(-1);
   break;
  END;
 END;
END;

export runme()
begin
 print();
 print("first page");
 waittap();
 print();
 print("second page");
 waittap();
 print();
 print("third page");
 waittap();
end;

I'll keep thinking and see what I can come up with.

Road
Find all posts by this user
Quote this message in a reply
07-18-2015, 04:48 PM (This post was last modified: 07-18-2015 05:04 PM by salvomic.)
Post: #7
RE: WAIT, PRINT and timeout
(07-18-2015 04:08 PM)roadrunner Wrote:  Hi Salvo,

I see what you mean. There appears to be no way to set the time out to more than a minute and wait for a key press at the same time.

I did come up with this code that won't skip the second page if you tap the screen, but if you accidently drag your finger on the screen it does skip the second page.

Code:

local waittap()
BEGIN
 LOCAL a;
 a:=1;
 WHILE a>0 DO
  a:=−WAIT(−1);
  IF TYPE(a)==6 THEN
   wait(-1);
   wait(-1);
   break;
  END;
 END;
END;

export runme()
begin
 print();
 print("first page");
 waittap();
 print();
 print("second page");
 waittap();
 print();
 print("third page");
 waittap();
end;

I'll keep thinking and see what I can come up with.

Road

hi Road,
this is interesting.
And it works, with tap (not with slide, drag). Better than nothing Wink
Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
07-18-2015, 07:14 PM
Post: #8
RE: WAIT, PRINT and timeout
If the screen dims, is there a standardised button that will un-dim it?
Without doing anything else?
(Comparable to hitting Shift on a PC, which is often the least intrusive key to press).

Or will we need logic like:
Wait until tap (but ignore tap in this pixel, except maybe for calling MAKEBRIGHT).

And if a program wants to ensure the screen is bright, is there such a routine - or is writing something to the screen sufficient to un-dim (if so, can you write NULL?)

I don't yet have a Prime to check for myself.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
07-18-2015, 07:32 PM
Post: #9
RE: WAIT, PRINT and timeout
(07-18-2015 07:14 PM)StephenG1CMZ Wrote:  If the screen dims, is there a standardised button that will un-dim it?
Without doing anything else?
(Comparable to hitting Shift on a PC, which is often the least intrusive key to press).

Or will we need logic like:
Wait until tap (but ignore tap in this pixel, except maybe for calling MAKEBRIGHT).

And if a program wants to ensure the screen is bright, is there such a routine - or is writing something to the screen sufficient to un-dim (if so, can you write NULL?)

I don't yet have a Prime to check for myself.

hi Stephen,
I don't think there are other way to un-dim, except ON+"plus", ON+"minus" or such a routine...

ciao, 73
Salvo (IT9CLU)

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
07-18-2015, 08:09 PM
Post: #10
RE: WAIT, PRINT and timeout
Recently TOff was added that lets you set the amount of time the calculator waits before turning off. Maybe TDim is in the near future?
Find all posts by this user
Quote this message in a reply
07-18-2015, 09:10 PM (This post was last modified: 07-18-2015 09:13 PM by StephenG1CMZ.)
Post: #11
RE: WAIT, PRINT and timeout
(07-18-2015 07:32 PM)salvomic Wrote:  
(07-18-2015 07:14 PM)StephenG1CMZ Wrote:  If the screen dims, is there a standardised button that will un-dim it?
Without doing anything else?
(Comparable to hitting Shift on a PC, which is often the least intrusive key to press).

Or will we need logic like:
Wait until tap (but ignore tap in this pixel, except maybe for calling MAKEBRIGHT).

And if a program wants to ensure the screen is bright, is there such a routine - or is writing something to the screen sufficient to un-dim (if so, can you write NULL?)

I don't yet have a Prime to check for myself.

hi Stephen,
I don't think there are other way to un-dim, except ON+"plus", ON+"minus" or such a routine...

ciao, 73
Salvo (IT9CLU)


I imagine the on + and on - change the brightness during use to adapt to ambient lighting...
I'd expect typing any key or tapping the screen to un-dim a screen that has temporarily dimmed as a power-saving change.

But I am seeking a key that will un-dim the screen without having a side-effect, such as pressing Enter maybe also causing a program to continue.

Or is it the case that when the screen has dimmed the only effect is to un-dim, without a program otherwise seeing that keypress and doing something (like responding to a prompt you cannot see because the screen was dimmed).

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
07-19-2015, 12:09 PM
Post: #12
RE: WAIT, PRINT and timeout
[/quote]
And it works, with tap (not with slide, drag). Better than nothing Wink
Salvo
[/quote]

Hi Salvo,

I modified the code to work with mouse drag. It behaves a little erratic with mouse long click. I didn't check to see what happens with mouse stretch, pinch, or rotate yet because I am doing this on the emulator and, alas, my computer doesn't have a touch screen.

road

Code:

local waittap()
BEGIN
 LOCAL a,b,c,d;
 a:=1;
 b:={};
 c:={};
 d:={1};
 WHILE a>0 DO
  a:=WAIT(−1);
  IF TYPE(a)==6 THEN
   b:=wait(-1);
   c:=wait(-1);
   if b(1)==2 then
   else
    while d(1)==1 do
     d:=wait(-1);
    end;
   end;
   break;
  end;
  a:=-a;
 END;
 return concat({a*1},{b*1},{c*1},{d*1});
END;

export runme()
begin
 print();
 print("first page");
 waittap();
 print();
 print("second page");
 waittap();
 print();
 print("third page");
 waittap();
 print();
 print("fourth page");
 waittap();
 print();
 print("fifth page");
 waittap();
 print();
 print("sixth page");
 waittap();
 print();
 print("seventh page");
 waittap();
end;
Find all posts by this user
Quote this message in a reply
07-19-2015, 03:35 PM
Post: #13
RE: WAIT, PRINT and timeout
(07-19-2015 12:09 PM)roadrunner Wrote:  Hi Salvo,

I modified the code to work with mouse drag. It behaves a little erratic with mouse long click. I didn't check to see what happens with mouse stretch, pinch, or rotate yet because I am doing this on the emulator and, alas, my computer doesn't have a touch screen.

road

hi Road,
many thanks!
it works here with tap and drag; with pinch I believe it pass over, however. But it's good enough so: normally the user uses only tap or drag to change page.

Soon I'll upload the new version (I must only solve the problem how to check if an app is active, to use it if yes), with credits also for you and your kindness Smile

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 3 Guest(s)