Author |
Topic: Sleep mode controls for Raspberry Pi 3 (modified) (Read 369 times) |
|
michael
Senior Member
member is offline


Posts: 335
|
 |
Sleep mode controls for Raspberry Pi 3 (modified)
« Thread started on: May 4th, 2017, 03:54am » |
|
With a bit of wisdom from Richard, I have made this control to keep things efficient Code: WAIT 1
REPEAT
k% = INKEY(4)
resp%=FNmoucheck
UNTIL k%<>-1 OR resp% >0
PRINT "done"
END
DEF FNmoucheck
PRIVATE mx%,my%,mb%,x%,y%,b%
MOUSE x%,y%,b%
IF mx%=0 AND my%=0 AND mb%=0 THEN mx%=x%:my%=y%:mb%=b%: =-1
IF mx%=x% AND my%=y% AND mb%=b% THEN =-1 ELSE mx%=x%:my%=y%:mb%=b%:=1
|
« Last Edit: May 4th, 2017, 12:05pm by michael » |
Logged
|
I like making program generators and like reinventing the wheel
|
|
|
DDRM
Administrator
member is offline


Gender: 
Posts: 321
|
 |
Re: Sleep mode controls for Raspberry Pi 3
« Reply #1 on: May 4th, 2017, 08:42am » |
|
Hi Michael,
So it just waits until you press a key or move/click the mouse, then wakes your program up again? I can see that being useful - for example, you could run a "screensaver" routine in the background, or security lock the program and demand a password to re-start.
One minor problem: you don't reset mx%,my% and mb% when you wake up again, so if you use the routine again it will report back immediately unless you are very lucky and leave the mouse EXACTLY where it was before...
One potential issue might be that the user wants the input they provide to be used. Would it be useful for your routine to return the button value and coordinates in some way - perhaps as parameters to your function?
Best wishes,
D
|
|
Logged
|
|
|
|
michael
Senior Member
member is offline


Posts: 335
|
 |
Re: Sleep mode controls for Pi 3- improved post
« Reply #2 on: May 4th, 2017, 12:02pm » |
|
This is an expansion on the topic that gives a returned key value.
This is a VERY efficient way to manage input from the keyboard, yet also keep the CPU cool
This modification is an expansion of Raspberry Pi topic which is greatly dependent on Richards solution,
It is highly valuable on BBCSDL and BBC4W ...
Code: k%=0:resp%=0
what%=0
REM This section gives a keypressed value that can be stored to a string
REPEAT
WAIT 1
what%=FNkeychk
IF what%>0 THEN PRINT STR$(what%)+" "+CHR$(what%)
UNTIL FALSE
END
REM keep FNkeychk and FNmoucheck together
REM ****************************************************************
DEFFNkeychk
REPEAT
k% = INKEY(4)
resp%=FNmoucheck
UNTIL k%<>-1 OR resp% >0
=k%
DEF FNmoucheck
PRIVATE mx%,my%,mb%,x%,y%,b%
MOUSE x%,y%,b%
IF mx%=0 AND my%=0 AND mb%=0 THEN mx%=x%:my%=y%:mb%=b%: =-1
IF mx%=x% AND my%=y% AND mb%=b% THEN =-1 ELSE mx%=x%:my%=y%:mb%=b%:=1
REM ********* END OF EFFICIENT CONTROLS ****************************
|
« Last Edit: Aug 15th, 2017, 01:59am by michael » |
Logged
|
I like making program generators and like reinventing the wheel
|
|
|
|