Wish AddListener

Discussion in 'B4R Bugs & Wishlist' started by Siam, Feb 1, 2019.

  1. Siam

    Siam Active Member Licensed User

    hi,

    AddListener is a great funktion but i miss the possibility to say by which signal addlistner should trigger
    (CHANGE, RISING or FALLING)

    I know i can check the Port but today i have found a issue that triggers the addlistner but the port was sometimes so fast back to low that I do not find out which signal has now triggered.

    as example i need the Rising trigger the falling i don't need so
    i have written a programm which checks the port if the port was high then do someting if the port is low do nothing.
    sometimes it works sometimes not this means my signal (which i can't change) is long enough for the addlistner but sometimes to short to to read by the port.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    The pin listener is very simple. It just checks every iteration, whether the current value is different than the previous value.

    You can create such a listener yourself with AddLooper.
     
    Siam likes this.
  3. Siam

    Siam Active Member Licensed User

    thanks for this information ! so its running ... solong i don't add some other code it seems we need a hardware interrupt for b4r ;)
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You can catch interrupts in libraries. Running code directly inside interrupts is problematic and is likely to break all kinds of things.
     
  5. Siam

    Siam Active Member Licensed User

    that means i can catch the interrupt and call a b4r sub directly from a library without any problems on b4r side?
     
  6. thetahsk

    thetahsk Member Licensed User

  7. Erel

    Erel Administrator Staff Member Licensed User

    Almost. It doesn't happen immediately. It goes through B4R message queue. See how receiveEvent is implemented in rWire.cpp.
     
    Siam likes this.
  8. Siam

    Siam Active Member Licensed User

    ok i will give it a try Thank you for this information
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice