jwhitehorn / pi_piper

Event driven Raspberry Pi GPIO programming in Ruby
BSD 2-Clause "Simplified" License
694 stars 71 forks source link

Pin#off? & Pin#on? not working as expected. #38

Closed elmatou closed 9 years ago

elmatou commented 9 years ago

EDIT : I understood, this behaviour is by design, but it do not seem very "natural" to me.

irb(main):007:0> r.on; r.on?
=> false

even if r is realy on a high level.

    def off?
      value == GPIO_LOW
    end

use the cached value of the pin (why a cached value ?!) which is not updated after #on or #off

    def off?
      read == GPIO_LOW
    end

is a way to fix the issue

glebe commented 9 years ago

it says in doc (http://www.rubydoc.info/github/jwhitehorn/pi_piper/PiPiper%2FPin%3Aread) that you should first call "read" to have actual state for "off?", value etc

would be good to update read me with some examples on that subject though