コード例 #1
1
ファイル: gpio_work.py プロジェクト: ZH8000/FlyCamera
# Import standard Python time library.
import time

# Import GPIO and FT232H modules.
import Adafruit_GPIO as GPIO
import Adafruit_GPIO.FT232H as FT232H

# Temporarily disable the built-in FTDI serial driver on Mac & Linux platforms.
FT232H.use_FT232H()

# Create an FT232H object that grabs the first available FT232H device found.
ft232h = FT232H.FT232H()

# Configure digital inputs and outputs using the setup function.
# Note that pin numbers 0 to 15 map to pins D0 to D7 then C0 to C7 on the board.
ft232h.setup(7, GPIO.IN)   # Make pin D7 a digital input.
ft232h.setup(8, GPIO.OUT)  # Make pin C0 a digital output.

# Loop turning the LED on and off and reading the input state.
print 'Press Ctrl-C to quit.'
while True:
	# Set pin C0 to a high level so the LED turns on.
	#ft232h.output(8, GPIO.HIGH)
	# Sleep for 1 second.
	#time.sleep(1)

	# Set pin C0 to a low level so the LED turns off.
	#ft232h.output(8, GPIO.LOW)
	# Sleep for 1 second.
	#time.sleep(1)
	# Read the input on pin D7 and print out if it's high or low.
コード例 #2
0
ファイル: usb_to_gpio.py プロジェクト: tslator/ArloBot
    def __init__(self):
        """
        Implements the Borg pattern which provides shared state among multiple objects
        """

        self.__dict__ = self.__shared_state

        try:
            # Temporarily disable the built-in FTDI serial driver on Mac & Linux platforms.
            FT232H.use_FT232H()
        except RuntimeError as rte:
            raise UsbToGpioError(rte)

        try:
            # Create an FT232H object that grabs the first available FT232H device found.
            self._ft232h = FT232H.FT232H()
        except RuntimeError as rte:
            raise UsbToGpioError(rte)

        # Create the I2C ADC devices
        try:
            # Create an I2C device at address ADS7828_ADDR_0
            self.ADCDevices.AddDevice(ADS7828(self._ft232h, self.__ADS7828_ADDR_0))

        except RuntimeError as rte:
            raise UsbToGpioError(rte)

        try:
            # Create an I2C device at address ADS7828_ADDR_1
            self.ADCDevices.AddDevice(ADS7828(self._ft232h, self.__ADS7828_ADDR_1))

        except RuntimeError as rte:
            raise UsbToGpioError(rte)
コード例 #3
0
def init_adafruit_ft232h():
    # Apply or remove the reset from the SPIROM daughterboard
    # via a GPIO on the AdaFruit FT232H SPI/I2C/UART/GPIO breakout board.
    global ft232h, adafruit_initialized

    if not adafruit_initialized:
        # Temporarily disable the built-in FTDI serial driver on Mac & Linux
        # platforms.
        FT232H.use_FT232H()

        # Create an FT232H object that grabs the first available FT232H device
        # found.
        ft232h = FT232H.FT232H()

        # The daughterboard reset line has a pull-up to 3v3. The "operate"
        # position of switch DW1.4 is "ON" which shorts it to ground (i.e.,
        # "Run" = Low, "Reset" = high). Even though the FT232H can nominally
        # drive the IO to 3v3, it would be better to instead simply tristate
        # the IO and let the pull-up do the work.
        # For initialization, we'll drive it low.
        ft232h.setup(SPIROM_RESET_GPIO, GPIO.OUT)

        ft232h.output(SPIROM_RESET_GPIO, GPIO.LOW)

        # Note that we're now initialized
        adafruit_initialized = True
コード例 #4
0
ファイル: girodicer.py プロジェクト: lasoren/ice-dam-drone
    def __init__(self, connection, baud, queue, debug=False):
        self.debug = debug
        self.eventQueue = queue
        self.eventQueue.addEventCallback(self.__roof_scan,EventHandler.SCAN_BORDER_FINISHED)
        print "Initializing vehicle"
        self.vehicle = connect(connection, baud=baud, wait_ready=True)
        self.vehicle.airspeed = self.flying_velocity
        self.vehicle.add_attribute_listener('battery', self.__battery_callback)
        print "Initializing lidar"
        FT232H.use_FT232H()
        self.ft232h = FT232H.FT232H()
        self.bus = FT232H.I2CDevice(self.ft232h, lidar.Lidar.DEF_ADDR)
        self.lidar = lidar.Lidar(self.bus)
        if not debug:
            print "Initializing bluetooth"
            self.blue = blue.Blue(self.eventQueue)
        else:
            print "Debug Mode On, No Bluetooth Running"
            self.blue = blue.Blue(self.eventQueue, debug)

        self.ft232h.setup(self.motor_pin, GPIO.OUT)
        self.ft232h.output(self.motor_pin, GPIO.LOW)
コード例 #5
0
ファイル: LoRa_main.py プロジェクト: njoubert/MaraudersMap
def main():
  log_to_stdout()

  FT232H.use_FT232H()
  ft232h = FT232H.FT232H()

  # Create a SPI interface from the FT232H using pin 8 (C0) as chip select.
  # Use a clock speed of 3mhz, SPI mode 0, and most significant bit first.
  spi = FT232H.SPI(ft232h, cs=8, max_speed_hz=3000000, mode=0, bitorder=FT232H.MSBFIRST)


  radio = LoRa(spi=spi, verbose=False)
  radio.set_freq(915)

  print radio

  a = raw_input("Transmit [T], Ping [P] or Receive [R]? ")

  if a == "P":
    try:
      while True:
        msg = "Ping: " + time.asctime()
        print msg
        transmit(radio, msg)
        time.sleep(1)
    except KeyboardInterrupt:
      pass
  elif a == "T":
    try:
      while True:
        msg = raw_input("Message:")
        transmit(radio, msg=msg)
    except KeyboardInterrupt:
      pass
  elif a == "R":
    receive_loop(radio)
  else:
    print "Unknown command:", a
コード例 #6
0
# Import standard Python time library.
import time
import subprocess

# Import GPIO and FT232H modules.
import Adafruit_GPIO as GPIO
import Adafruit_GPIO.FT232H as FT232H

# Temporarily disable the built-in FTDI serial driver on Mac & Linux platforms.
FT232H.use_FT232H()
#subprocess.call('sudo kextunload -b com.apple.driver.AppleUSBFTDI', shell=True)
#subprocess.call('sudo kextunload /System/Library/Extensions/FTDIUSBSerialDriver.kext', shell=True)
#subprocess.call('kextunload -bundle-id com.FTDI.driver.FTDIUSBSerialDriver', shell=True)
#subprocess.call('kextunload /System/Library/Extensions/FTDIUSBSerialDriver.kext', shell=True)

# Create an FT232H object that grabs the first available FT232H device found.
ft232h = FT232H.FT232H()

# Configure digital inputs and outputs using the setup function.
# Note that pin numbers 0 to 15 map to pins D0 to D7 then C0 to C7 on the board.
ft232h.setup(2, GPIO.IN)   # Make pin D7 a digital input.
ft232h.setup(8, GPIO.OUT)  # Make pin C0 a digital output.
ft232h.setup(9, GPIO.OUT)  # Make pin C0 a digital output.
ft232h.setup(10, GPIO.OUT)  # Make pin C0 a digital output.
ft232h.setup(11, GPIO.OUT)  # Make pin C0 a digital output.
ft232h.setup(12, GPIO.OUT)  # Make pin C0 a digital output.

# Loop turning the LED on and off and reading the input state.
print 'Press Ctrl-C to quit.'
while True:
	# Set pin C0 to a high level so the LED turns on.
コード例 #7
0
def use_FT4232H():
    FT232H.use_FT232H()