Sleep does not really sleep...


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,171


    Did you find this post helpful? Yes | No

    Default Re: Sleep does not really sleep...

    Hi Jerson.

    Thanks for the good points. Yes I will change the ISR to what you suggested. But in any case as it is now, it works very good. With your suggestion will be more efficient and fast in regards of ISR view.

    The PortB has Pull-Ups enabled so the line is correct as it is in the program.

    My only problem is how to check for key release instead of key press.

    Ioannis

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    971


    Did you find this post helpful? Yes | No

    Default Re: Sleep does not really sleep...

    Not too difficult to check for key release to act on.

    Right now you are checking a keypress when the portb value is different from $78

    Key release is simply getting the transition from (Not $78) to $78

    What caused it to be Not $78 is the key that got released.

    For easy implementation in case of short keypresses, a tight blocking loop doing the above test is fine. In case you anticipate the user will have a button down for a long while, then a different approach using a software timer may give better results.

    Just a short pseudo code as I am not well oiled in PBP these days

    Code:
    while 1
        key = ~portb & $78
        if (key <> $78) then
             savedkey = key
        else
             if savedkey <> $78 then
                  ' saved key is the one that was released
                  ' act on saved key
             endif
        endif
    wend
    If you wish to have a keyboard that has buttons that give pressed, hold, repeat and release states, I suggest you look at some arduino code that shows such an implementation using a finite state machine

Similar Threads

  1. Asm sleep - pbp sleep
    By MOUNTAIN747 in forum mel PIC BASIC Pro
    Replies: 31
    Last Post: - 18th May 2020, 22:13
  2. Can't @sleep
    By MOUNTAIN747 in forum General
    Replies: 3
    Last Post: - 30th December 2010, 18:29
  3. Trying to add a sleep function or pretend to sleep
    By lilimike in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 9th May 2010, 20:10
  4. How to go to sleep
    By savnik in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 22nd September 2006, 19:38
  5. @sleep
    By jheissjr in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 5th March 2006, 23:42

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts