BBC BASIC for Windows
« Sleep mode controls for Raspberry Pi 3 (modified) »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:42pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Sleep mode controls for Raspberry Pi 3 (modified)  (Read 370 times)
michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
xx 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 » User IP Logged

I like making program generators and like reinventing the wheel
DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
xx 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
User IP Logged

michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
xx 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 » User IP Logged

I like making program generators and like reinventing the wheel
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls