Commit 93eef089 authored by fxk8y's avatar fxk8y 🕷
Browse files

Working blinking example

parent 61468333
#!/usr/bin/env nix-shell
#!nix-shell -i python -p less -p "python3.withPackages (p: with p; [pyftdi])" --pure
#!nix-shell -i python -p less -p "python3.withPackages (p: with p; [pyftdi pyyaml])" --pure
from time import sleep
from pyftdi.eeprom import FtdiEeprom
from pyftdi.ftdi import Ftdi, FtdiError
# import pdb; pdb.set_trace()
eeprom = FtdiEeprom()
......@@ -17,19 +19,21 @@ ftdi = Ftdi()
ftdi.open_from_url('ftdi:///1')
# sanity check: device should support CBUS feature
# self.assertEqual(ftdi.has_cbus, True)
eeprom = FtdiEeprom()
eeprom.connect(ftdi)
print('EEPROM: {}'.format(eeprom.properties))
# sanity check: device should have been configured for CBUS GPIOs
# self.assertEqual(eeprom.cbus_mask & 0b1001, 0b1001)
# configure CBUS0 and CBUS3 as output
ftdi.set_cbus_direction(0b1001, 0b1001)
# configure CBUS0 to CBUS3 as output
ftdi.set_cbus_direction(0b1111, 0b1111)
# no input pin available
# self.assertRaises(FtdiError, ftdi.get_cbus_gpio)
......@@ -37,8 +41,8 @@ ftdi.set_cbus_direction(0b1001, 0b1001)
frame = 0
while True:
ftdi.set_cbus_gpio(frame & 0b1001)
ftdi.set_cbus_gpio(frame & 0b1111)
frame += 1
sleep(0.1)
sleep(0.04)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment