예제 #1
0
def setup():
	#PWM.start(channel, duty, freq=2000, polarity=0)
	#duty values are valid 0 (off) to 100 (on)
	GPIO.setup(pin_forward, GPIO.OUT)
	GPIO.setup(pin_back, GPIO.OUT)
	PWM.start(pin_pwm, 0, 800, 0)
	motorStop()
예제 #2
0
 def act(self, client_address, state, name):
     print "State", state, "from client @", client_address
     GPIO.setmode(GPIO.BOARD)  ## Use board pin numbering
     GPIO.setup(str(sys.argv[3]), GPIO.OUT)  ## Setup GPIO Pin to OUTPUT
     GPIO.output(str(sys.argv[3]), not state)  ## State is true/false
     GPIO.cleanup(str(sys.argv[3]))
     return True
예제 #3
0
 def test_setup_expanded_gpio(self):
     GPIO.setup("XIO-P1", GPIO.OUT)
     base = GPIO.get_gpio_base() + 1
     gfile = '/sys/class/gpio/gpio%d' % base
     assert os.path.exists(gfile)
     GPIO.cleanup()
     assert not os.path.exists(gfile)
예제 #4
0
 def test_setup_expanded_gpio(self):
     GPIO.setup("XIO-P1", GPIO.OUT)
     base = GPIO.get_gpio_base() + 1
     gfile = '/sys/class/gpio/gpio%d' % base
     assert os.path.exists(gfile)
     GPIO.cleanup()
     assert not os.path.exists(gfile)
예제 #5
0
    def init(self):
        app.logger.info("INIT GPIO")
        try:
            app.logger.info(app.brewapp_hardware_config)
            for h, hw in app.brewapp_hardware_config.items():
                app.logger.info(hw)

                g = hw["config"]["switch"]
                app.logger.info(g)

                if not g:
                    continue

                app.logger.info("SETUP HARDWARE: " + str(h) + " GPIO: " +
                                str(g))
                GPIO.setup(g, GPIO.OUT)

                if self.getConfigValue(h, "inverted", False):
                    app.logger.warning("SETUP INVERTED")
                    GPIO.output(g, GPIO.HIGH)
                else:
                    app.logger.warning("SETUP NOT INVERTED")
                    GPIO.output(g, GPIO.LOW)

            app.brewapp_gpio = True
            self.state = True
            app.logger.info("ALL GPIO INITIALIZED")

        except Exception as e:
            app.logger.error("SETUP GPIO FAILD " + str(e))
            app.brewapp_gpio = False
            self.state = False
예제 #6
0
	def __init__(self, _outpins):
		self.outpins = _outpins # { 'zone_00' : 17, 'zone_01': 18, etc... }
		# Set the Zone / Gate Pins High
		for item in self.outpins:
			pin_name = "XIO-P" + str(self.outpins[item])
			GPIO.setup(pin_name, GPIO.OUT)
			GPIO.output(pin_name, GPIO.HIGH)
예제 #7
0
def transmit_code(code):
    '''Transmit a chosen code string using the GPIO transmitter'''
    #    GPIO.setmode(GPIO.BCM)
    GPIO.setup(TRANSMIT_PIN, GPIO.OUT)
    for t in range(NUM_ATTEMPTS):
        for i in code:
            if i == '1':
                GPIO.output(TRANSMIT_PIN, 1)
                time.sleep(.00055)
                GPIO.output(TRANSMIT_PIN, 0)
            elif i == '2':
                GPIO.output(TRANSMIT_PIN, 0)
                time.sleep(.00011)
                GPIO.output(TRANSMIT_PIN, 1)
            elif i == '3':
                GPIO.output(TRANSMIT_PIN, 0)
                time.sleep(.000303)
                GPIO.output(TRANSMIT_PIN, 1)
            elif i == '4':
                GPIO.output(TRANSMIT_PIN, 1)
                time.sleep(.00011)
                GPIO.output(TRANSMIT_PIN, 0)
            elif i == '5':
                GPIO.output(TRANSMIT_PIN, 1)
                time.sleep(.00029)
                GPIO.output(TRANSMIT_PIN, 0)
            else:
                continue
        GPIO.output(TRANSMIT_PIN, 0)
    GPIO.cleanup()
예제 #8
0
    def init(self):
        app.logger.info("INIT GPIO")
        try:
            app.logger.info(app.brewapp_hardware_config)
            for h, hw in app.brewapp_hardware_config.items():
                app.logger.info(hw)

                g = hw["config"]["switch"]
                app.logger.info(g)

                if not g:
                    continue

                app.logger.info("SETUP HARDWARE: " + str(h) + " GPIO: " + str(g))
                GPIO.setup(g, GPIO.OUT)

                if self.getConfigValue(h, "inverted", False):
                    app.logger.warning("SETUP INVERTED")
                    GPIO.output(g, GPIO.HIGH)
                else:
                    app.logger.warning("SETUP NOT INVERTED")
                    GPIO.output(g, GPIO.LOW)

            app.brewapp_gpio = True
            self.state = True
            app.logger.info("ALL GPIO INITIALIZED")

        except Exception as e:
            app.logger.error("SETUP GPIO FAILD " + str(e))
            app.brewapp_gpio = False
            self.state = False
예제 #9
0
 def act(self, client_address, state, name):
     print "State", state, "from client @", client_address
     GPIO.setmode(GPIO.BOARD) ## Use board pin numbering
     GPIO.setup(str(sys.argv[3]), GPIO.OUT)   ## Setup GPIO Pin to OUTPUT
     GPIO.output(str(sys.argv[3]), not state) ## State is true/false
     GPIO.cleanup(str(sys.argv[3]))
     return True
예제 #10
0
    def __init__(self,
                 pin_dt,
                 pin_clk,
                 pullup=GPIO.PUD_OFF,
                 clicks=1,
                 min_val=0,
                 max_val=100,
                 accel=0,
                 reverse=False):
        self.pin_dt = pin_dt
        self.pin_clk = pin_clk
        self.min_val = min_val * clicks
        self.max_val = max_val * clicks
        self.accel = int((max_val - min_val) / 100 * accel)
        self.max_accel = int((max_val - min_val) / 2)
        self.clicks = clicks
        self.reverse = 1 if reverse else -1
        self._value = 0
        self._readings = 0
        self._state = 0
        self.cur_accel = 0

        GPIO.setup(pin_dt, GPIO.IN, pullup)
        GPIO.setup(pin_clk, GPIO.IN, pullup)
        self.set_callbacks(self._cb)
예제 #11
0
def testFreq():

    GPIO.setup("CSID1", GPIO.OUT)

    while True:  # do 24 times
        # Pulse the ADC once
        GPIO.output("CSID1", GPIO.HIGH)  # push to high to get the value
        GPIO.output("CSID1", GPIO.LOW)  # end low
예제 #12
0
def switches_setup():
    ports = ["U14_13", "U14_14", "U14_15", "U14_16"]
    for port in ports:
        try:
            GPIO.setup(port, GPIO.IN)
        except RuntimeError:
            print("Couldn't set up port", port)
            pass
예제 #13
0
 def disable_tx(self):
     """Disable TX, reset GPIO."""
     if self.tx_enabled:
         # set up GPIO pin as input for safety
         GPIO.setup(self.gpio, GPIO.IN)
         self.tx_enabled = False
         _LOGGER.debug("TX disabled")
     return True
예제 #14
0
def switches_setup():
	ports=["U14_13","U14_14","U14_15","U14_16"]
	for port in ports:
		try:
			GPIO.setup(port, GPIO.IN)
		except RuntimeError:
			print("Couldn't set up port",port)
			pass
예제 #15
0
파일: rfid.py 프로젝트: drbobbob/rfidreader
    def setup_gpio(self):

        GPIO.setwarnings(False)
        try:
            GPIO.setmode(GPIO.BOARD)
        except AttributeError:
            pass
        GPIO.setup(self.pin, GPIO.OUT)
        GPIO.output(self.pin, True)
 def test_input(self):
     GPIO.setup("CSID6", GPIO.IN)
     #returned as an int type
     input_value = GPIO.input("CSID6")
     #value read from the file will have a \n new line
     value = open('/sys/class/gpio/gpio138/value').read()
     assert int(value) == input_value
     # time.sleep(30) - what is this for?
     GPIO.cleanup()
예제 #17
0
def switches_setup():
	try:
		GPIO.setup("U14_13", GPIO.IN)
		GPIO.setup("U14_14", GPIO.IN)
		GPIO.setup("U14_15", GPIO.IN)
		GPIO.setup("U14_16", GPIO.IN)
		GPIO.setup("U14_17", GPIO.IN)
	except RuntimeError:
		pass
예제 #18
0
파일: start.py 프로젝트: pimpmypixel/dejavu
def blinkLed(blinks):
    GPIO.setup("XIO-P0", GPIO.OUT)
    for j in range(1, blinks):
        GPIO.output("XIO-P0", GPIO.LOW)
        time.sleep(0.05)
        GPIO.output("XIO-P0", GPIO.HIGH)
        time.sleep(0.05)
    GPIO.cleanup()
    return
예제 #19
0
 def test_input(self):
     GPIO.setup("CSID6", GPIO.IN)
     #returned as an int type
     input_value = GPIO.input("CSID6")
     #value read from the file will have a \n new line
     value = open('/sys/class/gpio/gpio138/value').read()
     assert int(value) == input_value
     time.sleep(30)
     GPIO.cleanup()
예제 #20
0
def input_setup(device):
    # If the device is set to 'Input' and internal resistor 'Pull Up' 
    if (pass_data['devices'][device]['pullup_pulldown'] == 'Pull Up' 
            and pass_data['devices'][device]['input_output'] == 'Input'):
        GPIO.setup(pass_data['devices'][device]['pin'], GPIO.IN, pull_up_down=GPIO.PUD_UP)
    # If the device is set to 'Input' and internal resistor 'Pull Down'
    elif (pass_data['devices'][device]['pullup_pulldown'] == 'Pull Down' 
            and pass_data['devices'][device]['input_output'] == 'Input'):
        GPIO.setup(pass_data['devices'][device]['pin'], GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
예제 #21
0
    def __init__(self, color, inputPin, outputPin):
        self.__color = color
        self.__outputPin = outputPin
        self.__inputPin = inputPin
        self._isOn = False

        GPIO.setup(outputPin, GPIO.OUT)
        GPIO.setup(inputPin, GPIO.IN)
        GPIO.output(outputPin,
                    GPIO.HIGH)  # turn LED off (active low common cathode form)
예제 #22
0
 def enable_tx(self):
     """Enable TX, set up GPIO."""
     if self.rx_enabled:
         _LOGGER.error("RX is enabled, not enabling TX")
         return False
     if not self.tx_enabled:
         self.tx_enabled = True
         GPIO.setup(self.gpio, GPIO.OUT)
         _LOGGER.debug("TX enabled")
     return True
예제 #23
0
 def __init__(self, pin, *args, **kwargs):
     self.pin = pin
     try:
         # TODO(mitch): figure out why this throws exceptions sometimes
         GPIO.setup(self.pin, GPIO.IN, GPIO.PUD_UP)
     except Exception as e:
         print("Got exception {} when trying to initialize {}".format(
             str(e), self.pin))
         pass
     super(Switch, self).__init__(*args, **kwargs)
예제 #24
0
    def __init__(self, channel, initial_state=False, open_value=True):
        self.chnl = channel

        init_val = 0
        if initial_state:
            init_val = 1

        self.ov = open_value

        gpio.cleanup(channel)
        gpio.setup(channel, gpio.OUT, initial=init_val)
예제 #25
0
def initBuzzer():

    buzzer_gpio = app.brewapp_config.get("BUZZER_GPIO", None)
    app.logger.info("BUZZER GPIO: " + str(buzzer_gpio))
    try:
        if buzzer_gpio is not None:
            GPIO.setmode(GPIO.BCM)
            GPIO.setup(buzzer_gpio, GPIO.OUT)

    except Exception as e:
        app.logger.error(e)
예제 #26
0
 def enable_rx(self):
     """Enable RX, set up GPIO and add event detection."""
     if self.tx_enabled:
         _LOGGER.error("TX is enabled, not enabling RX")
         return False
     if not self.rx_enabled:
         self.rx_enabled = True
         GPIO.setup(self.gpio, GPIO.IN)
         GPIO.add_event_detect(self.gpio, GPIO.BOTH)
         GPIO.add_event_callback(self.gpio, self.rx_callback)
         _LOGGER.debug("RX enabled")
     return True
예제 #27
0
def chip():
    import CHIP_IO.GPIO as GPIO
    trigger = i.cfg['chip']['trigger_pin']
    light = i.cfg['chip']['relay_pin']
    GPIO.setup(trigger, GPIO.OUT)
    GPIO.setup(light, GPIO.OUT)
    GPIO.output(light, GPIO.HIGH)
    f.playAudio(i.intro)
    f.playAudio(i.alarm)
    f.playAudio(i.voice)
    GPIO.output(light, GPIO.LOW)
    return
예제 #28
0
def output_setup(device):
    # If the device is set to 'Output'
    if pass_data['devices'][device]['input_output'] == 'Output':
            GPIO.setup(pass_data['devices'][device]['pin'], GPIO.OUT) # Set the pin to output
    # If the device is set to 'Output' and the default state is 'High'
    elif (pass_data['devices'][device]['defaultstate'] == 'High' 
            and pass_data['devices'][device]['input_output'] == 'Output'):
        GPIO.output(pass_data['devices'][device]['pin'], GPIO.HIGH) # Set the pin state High
    # If the device is set to 'Output' and the default state is 'Low'
    elif (pass_data['devices'][device]['defaultstate'] == 'Low' 
            and pass_data['devices'][device]['input_output'] == 'Output'):
        GPIO.output(pass_data['devices'][device]['pin'], GPIO.LOW) # Set the pin state to Low
예제 #29
0
    def __init__(self):
        Thread.__init__(self)
        self.running = True
        self.teste = 0

        self.bluetooth = serial.Serial(port=self.rfcomm, baudrate=self.baudrate)
        self.bluetooth.close()
        self.bluetooth.open()
        self.bus = smbus.SMBus(2)

        GPIO.setup('XIO-P0', GPIO.OUT)
        GPIO.output('XIO-P0', GPIO.LOW)
예제 #30
0
    def GET(self, arguments):
        try:
            GPIO.cleanup()
            GPIO.setup("XIO-P0", GPIO.OUT)

            print "Toggling the door...."
            GPIO.output("XIO-P0", GPIO.HIGH)
            time.sleep(.5)
            GPIO.output("XIO-P0", GPIO.LOW)
            GPIO.cleanup()
            return "<html><body>Door was toggled!</body></html>"
        except:
            return "<html><bod>Error calling GPIO pin</bod></html>"
예제 #31
0
	def run(self):
		# GPIO.toggle_debug()

		try:
			# reset all
			ioutil.unexport_all()
			# GPIO.cleanup()  -- broken?

			# led
			GPIO.setup(LED, GPIO.OUT)
			GPIO.output(LED, GPIO.LOW)

			# handset
			GPIO.setup(HANDSET, GPIO.IN, pull_up_down=GPIO.PUD_UP, initial=1)
			GPIO.add_event_detect(HANDSET, GPIO.BOTH, self.off_hook)

			# rotary dial
			GPIO.setup(ROT_ENGAGED, GPIO.IN, pull_up_down=GPIO.PUD_UP)
			GPIO.add_event_detect(ROT_ENGAGED, GPIO.BOTH, self.rotary_engaged)
			GPIO.setup(ROT_PULSE, GPIO.IN, pull_up_down=GPIO.PUD_UP)
			GPIO.add_event_detect(ROT_PULSE, GPIO.FALLING, self.count_pulse)
		except Exception as e:
			logging.exception("exception encountered")

		GPIO.output(LED, GPIO.LOW) # signal process has started successfully

		# busy loop
		while True:
			time.sleep(0.02)
예제 #32
0
 def __init__(self, spi, ch):
   self.spi = spi
   self.channel = ch
   self.avg = 1
   self.adc = 0
   
   # configure conversion complete pin
   GPIO.setup("AP-EINT1", GPIO.IN)
   
   # configure ADC
   self.configSPI()
   self.spi.write([0x18]) # reset
   self.spi.write([0x68]) # internal vref, self timed conversions
   self.spi.write([0x40]) # no averaging
예제 #33
0
 def __init__(self):
     print('init')
     GPIO.setup("XIO-P2", GPIO.OUT, initial=1)
     GPIO.setup("XIO-P3", GPIO.OUT, initial=1)
     GPIO.setup("XIO-P4", GPIO.OUT, initial=1)
     GPIO.setup("XIO-P5", GPIO.OUT, initial=1)
     GPIO.setwarnings(False)
예제 #34
0
def configGPIO(pin):
    if not settings['triggerActive']:
        if not settings['SIMULATE']:
            import CHIP_IO.GPIO as GPIO
            # Config GPIO pin for pull down
            # and detection of rising edge
            GPIO.cleanup(pin)
            GPIO.setup(pin, GPIO.IN, GPIO.PUD_DOWN)
            GPIO.add_event_detect(pin, GPIO.RISING)
            GPIO.add_event_callback(pin, S0Trigger)
        settings['triggerActive'] = True
        logMsg("Setting up S0-Logger on " + pin)
    else:
        logMsg("Trigger already active on " + pin)
예제 #35
0
def main():
    logging.basicConfig(level=logging.INFO,
                        format='%(levelname)s: %(message)s')

    GPIO.cleanup(pin)
    GPIO.setup(pin, GPIO.IN)

    # Add Callback for Both Edges using the add_event_detect() method
    GPIO.add_event_detect(pin, GPIO.FALLING, doorbell_handler)

    try:
        while (not time.sleep(5)):
            print("watching " + pin)
    except:
        GPIO.cleanup(pin)
예제 #36
0
파일: burnGPIO.py 프로젝트: xranby/burnLVP
def Setup_Interface():
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BOARD)
    MGPIO.setup(PIC_MCLR, GPIO.OUT)
    MGPIO.output(PIC_MCLR, False)
    MGPIO.setup(PIC_CLK, GPIO.OUT)
    MGPIO.setup(PIC_DATA, GPIO.OUT)
    MGPIO.setup(PIC_PGM, GPIO.OUT)
예제 #37
0
    def api_digital_read(self, pin):
        resp = copy.deepcopy(self.CHIP_INFO)
        resp["connected"] = True

        pin = pin.upper()

        # Setup pin if it isn't already and then add it
        if pin not in self.PINS_IN_USE:
            GPIO.setup(pin, GPIO.IN)
            self.PINS_IN_USE.append(pin)

        # Read the pin
        resp["message"] = GPIO.input(pin)

        return jsonify(resp)
예제 #38
0
def Setup_Interface():
  GPIO.setwarnings(False)
  GPIO.setmode(GPIO.BOARD)
  MGPIO.setup(PIC_MCLR,GPIO.OUT)
  MGPIO.output(PIC_MCLR,False)
  MGPIO.setup(PIC_CLK,GPIO.OUT)
  MGPIO.setup(PIC_DATA,GPIO.OUT)
  MGPIO.setup(PIC_PGM,GPIO.OUT)
예제 #39
0
    def __init__(self, spi_bus, spi_device, reset_pin):
        self.spi = spidev.SpiDev()
        self.spi.open(spi_bus, spi_device)
        self.reset_pin = reset_pin

        if hasattr(GPIO, "setmode"):
            GPIO.setmode(GPIO.BOARD)

        try:
            GPIO.setup(self.reset_pin, GPIO.OUT)
        except:
            pass

        GPIO.output(self.reset_pin, GPIO.HIGH)
        self.RC522_Init()
예제 #40
0
파일: rfid.py 프로젝트: drbobbob/rfidreader
 def manual_release(self, connection):
     GPIO.setup(buttonPin,GPIO.IN, pull_up_down = GPIO.PUD_UP)
     self.connection = True
     while True:
         if(GPIO.input(buttonPin) == False):
             time.sleep(.1)
             if(GPIO.input(buttonPin) == False):
                 logger.info("******** Start Message ********")
                 self.solenoid.open_door()
                 logger.info("********* End Message *********")
                 count = 0
                 while(GPIO.input(buttonPin) == False):
                     time.sleep(.1)
                     count += 1
                     if count == 40:
                         self.solenoid.blink_door()
                         sp.call(update_script)
                         self.solenoid.blink_door()
             else:
                 logger.info("******* Missed Debounce *******")
예제 #41
0
	def setup(self):
		GPIO.setwarnings(False)
		GPIO.cleanup()
		GPIO.setup(self.__pconfig['button'], GPIO.IN, pull_up_down=GPIO.PUD_UP)
		GPIO.setup(self.__pconfig['rec_light'], GPIO.OUT) # lights'], GPIO.OUT)
		GPIO.setup(self.__pconfig['plb_light'], GPIO.OUT) # lights'], GPIO.OUT)
		GPIO.output(self.__pconfig['rec_light'], GPIO.LOW)
		GPIO.output(self.__pconfig['plb_light'], GPIO.LOW)
예제 #42
0
def setup():
    """Setup GPIO ports"""
    print("Setting up SPI GPIO connections..."),
    #Setup GPIO pins
    GPIO.setup(PIN_SDI, GPIO.OUT)
    GPIO.setup(PIN_SDO, GPIO.IN)
    GPIO.setup(PIN_SCK, GPIO.OUT)

    #Initialize output pins
    GPIO.output(PIN_SDI, GPIO.LOW)
    GPIO.output(PIN_SCK, GPIO.LOW)
    print("[DONE]")
예제 #43
0
 def __init__(self, pinA, pinB, button, callback):
     self.pinA = pinA
     self.pinB = pinB
     self.button = button
     self.callback = callback
     GPIO.setmode(GPIO.BCM)
     GPIO.setwarnings(False)
     GPIO.setup(self.pinA, GPIO.IN, pull_up_down=GPIO.PUD_UP)
     GPIO.setup(self.pinB, GPIO.IN, pull_up_down=GPIO.PUD_UP)
     GPIO.setup(self.button, GPIO.IN, pull_up_down=GPIO.PUD_UP)
     GPIO.add_event_detect(self.pinA, GPIO.FALLING, callback=self.switch_event)
     GPIO.add_event_detect(self.pinB, GPIO.FALLING, callback=self.switch_event)
     GPIO.add_event_detect(self.button, GPIO.BOTH, callback=self.button_event, bouncetime=200)
예제 #44
0
 def setup():
     """ Configure the CHIP GPIOs
     :rtype : None
     """
     # LED
     GPIO.setup(BOARD.LED, GPIO.OUT)
     GPIO.output(BOARD.LED, 1)
     # switch
     GPIO.setup(BOARD.SWITCH, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
     # DIOx
     for gpio_pin in [BOARD.DIO0, BOARD.DIO1, BOARD.DIO2, BOARD.DIO3]:
         GPIO.setup(gpio_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
     # blink 2 times to signal the board is set up
     BOARD.blink(.1, 2)
예제 #45
0
 def test_setup_failed_value_error(self):
     with pytest.raises(ValueError):
         GPIO.setup("U14_37", 3)
         GPIO.cleanup()
예제 #46
0
def initialize():
  for i in gpio:
    GPIO.setup(i, GPIO.OUT, initial=GPIO.LOW)
예제 #47
0
            print(mystr)
            GPIO.output("CSID0", GPIO.HIGH)
        print(" LOOP FUNCTION SLEEPING")
        time.sleep(1)

num_errs = 0

print("GETTING CHIP_IO VERSION")
mystr = "CHIP_IO VERSION: %s" % GPIO.VERSION
print(mystr)

print("\nRUNNING GPIO SELF TEST")
GPIO.selftest(0)

print("\nVERIFYING SIMPLE FUNCTIONALITY")
GPIO.setup("GPIO1", GPIO.IN)
GPIO.setup("CSID0", GPIO.OUT, initial=GPIO.HIGH)
if (GPIO.input("GPIO1") != GPIO.HIGH):
    print(" A high output on CSI0 does not lead to a high input on XIO-P2.")
    print(" Perhaps you forgot to connect them?")
    num_errs += 1
else:
    print(" Able to use alternate names for GPIO")
GPIO.cleanup()

GPIO.setup("U14_15", GPIO.IN)  # XIO-P2
GPIO.setup("CSID0", GPIO.OUT, initial=GPIO.LOW)
if (GPIO.input("XIO-P2") != GPIO.LOW):
    print(" A low output on CSI0 does not lead to a low input on XIO-P2.")
    print(" Perhaps you forgot to connect them?")
    num_errs += 1
예제 #48
0
 def value(self):
     if self.direction != "in":
         self.direction = "in"
         GPIO.setup(self.pin, GPIO.IN)
     return GPIO.input(self.pin)
예제 #49
0
 def test_direction_readback(self):
     GPIO.setup("CSID6", GPIO.IN)
     direction = GPIO.gpio_function("CSID6")
     assert direction == GPIO.IN
예제 #50
0
 def value(self, val):
     if self.direction != "out":
         self.direction = "out"
         GPIO.setup(self.pin, GPIO.OUT)
     GPIO.output(self.pin, GPIO.HIGH if val else GPIO.LOW)
예제 #51
0
 def test_setup_input_pull_down(self):
     GPIO.setup("U14_37", GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
     assert os.path.exists('/sys/class/gpio/gpio138')
     direction = open('/sys/class/gpio/gpio138/direction').read()
     assert direction == 'in\n'
     GPIO.cleanup()
예제 #52
0
 def test_setup_cleanup(self):
     GPIO.setup("U14_37", GPIO.OUT)
     assert os.path.exists('/sys/class/gpio/gpio138')
     GPIO.cleanup()
     assert not os.path.exists('/sys/class/gpio/gpio138')
예제 #53
0
 def test_setup_failed_type_error(self):
     with pytest.raises(TypeError):
         GPIO.setup("U14_37", "WEIRD")
         GPIO.cleanup()
예제 #54
0
def configure_pins():
  GPIO.cleanup()
  for index in range(0,6):
    GPIO.setup(hour_leds[index], GPIO.OUT)
    GPIO.setup(minute_leds[index], GPIO.OUT)
    GPIO.setup(second_leds[index], GPIO.OUT)
예제 #55
0
 def test_setup_expanded_gpio(self):
     GPIO.setup("XIO-P1", GPIO.OUT)
     assert os.path.exists('/sys/class/gpio/gpio409')
     GPIO.cleanup()
     assert not os.path.exists('/sys/class/gpio/gpio409')
예제 #56
0
 def test_setup_output_key(self):
     GPIO.setup("U14_37", GPIO.OUT)
     assert os.path.exists('/sys/class/gpio/gpio138')
     direction = open('/sys/class/gpio/gpio138/direction').read()
     assert direction == 'out\n'
     GPIO.cleanup()
예제 #57
0
from wiki_api import CalangoWiki
wiki = CalangoWiki()

def status_atual():
    """Verifica no site o status atual (aberto ou fechado)"""
    return wiki.conteudo_pagina("status")


def muda_status(status):
    """Atualiza a wiki com o status selecionado"""
    wiki.atualiza_pagina('status', status)



    #opções = 'Aberto Fechado'.split()
    

if __name__ == '__main__':

        GPIO.setup("CSID0",GPIO.IN) 
        while 1:
           if GPIO.input("CSID0"):
                   muda_status("Fechado")  
                   print("HIGH")
           else: 
                   muda_status("Aberto")  
                   print("LOW") 
           time.sleep(300)
                   
                   
예제 #58
0
    print "CALLBACK LIKE DRAKE IN HOTLINE BLING"
    
def loopfunction():
    print "LOOP FUNCTION"
    for i in xrange(20):
        if i % 2:
            print "SETTING CSID0 LOW"
            GPIO.output("CSID0",GPIO.LOW)
        else:
            print "SETTING CSID0 HIGH"
            GPIO.output("CSID0",GPIO.HIGH)
        print "SLEEPING"
        time.sleep(1)
    
print "SETUP XIO-P0"
GPIO.setup("XIO-P0", GPIO.IN)

print "SETUP CSID0"
GPIO.setup("CSID0", GPIO.OUT)

# VERIFY SIMPLE FUNCTIONALITY
print "VERIFY SIMPLE FUNCTIONALITY"

print "READING XIO-PI"
GPIO.output("CSID0", GPIO.HIGH)
print "HIGH", GPIO.input("XIO-P0")

GPIO.output("CSID0", GPIO.LOW)
print "LOW", GPIO.input("XIO-P0")

# ==============================================
예제 #59
0
파일: blink.py 프로젝트: trafferty/utils
#!/usr/bin/python

import time
import argparse
import CHIP_IO.GPIO as GPIO

def blink(n, f):
    t = (1.0/f) / 2.0
    GPIO.output("CSID0", 0)
    for x in range(n+1):
        GPIO.output("CSID0", 1)
        time.sleep(t)
        GPIO.output("CSID0", 0)
        time.sleep(t)

if __name__ == "__main__":
    '''
    parseDIFLog.py -i file_to_parse
    '''
    parser = argparse.ArgumentParser(description='open process log file, parse it according to parse function')
    parser.add_argument('-n',  dest='num_cycles', type=int, help='number of cycles')
    parser.add_argument('-f',  dest='freq', type=int, help='frequency in Hz')

    args = parser.parse_args()

    GPIO.setup("CSID0", GPIO.OUT)
    blink(100, 0.1)


예제 #60
0
 def test_setup_input_name(self):
     GPIO.setup("CSID6", GPIO.IN)
     assert os.path.exists('/sys/class/gpio/gpio138')
     direction = open('/sys/class/gpio/gpio138/direction').read()
     assert direction == 'in\n'
     GPIO.cleanup()