예제 #1
0
파일: gpio.py 프로젝트: sintrb/PyBBIO
def digitalWrite(gpio_pin, state):
    """ Writes given digital pin low if state=0, high otherwise. """
    assert (gpio_pin in GPIO), "*Invalid GPIO pin: '%s'" % gpio_pin
    gpio_file = getGPIOStateFile(gpio_pin)
    if not os.path.exists(gpio_file):
        print "warning: digitalWrite() failed, pin '%s' not exported." % gpio_pin +\
              " Did you call pinMode()?"
        return
    if (state):
        sysfs.kernelFilenameIO(gpio_file, '1')
    else:
        sysfs.kernelFilenameIO(gpio_file, '0')
예제 #2
0
파일: gpio.py 프로젝트: GeeksWine/PyBBIO
def digitalWrite(gpio_pin, state):
  """ Writes given digital pin low if state=0, high otherwise. """
  assert (gpio_pin in GPIO), "*Invalid GPIO pin: '%s'" % gpio_pin
  gpio_file = getGPIOStateFile(gpio_pin)
  if not os.path.exists(gpio_file):
    print "warning: digitalWrite() failed, pin '%s' not exported." % gpio_pin +\
          " Did you call pinMode()?" 
    return
  if (state):    
    sysfs.kernelFilenameIO(gpio_file, '1')
  else:
    sysfs.kernelFilenameIO(gpio_file, '0')
예제 #3
0
파일: gpio.py 프로젝트: sintrb/PyBBIO
def digitalRead(gpio_pin):
    """ Returns input pin state as 1 or 0. """
    assert (gpio_pin in GPIO), "*Invalid GPIO pin: '%s'" % gpio_pin
    gpio_file = getGPIOStateFile(gpio_pin)
    return int(sysfs.kernelFilenameIO(gpio_file))
예제 #4
0
파일: gpio.py 프로젝트: GeeksWine/PyBBIO
def digitalRead(gpio_pin):
  """ Returns input pin state as 1 or 0. """
  assert (gpio_pin in GPIO), "*Invalid GPIO pin: '%s'" % gpio_pin
  gpio_file = getGPIOStateFile(gpio_pin)
  return int(sysfs.kernelFilenameIO(gpio_file))