examples Package¶
examples
Package¶
pylibftdi examples
bit_server
Module¶
bit_server.py - remote HTTP interface to bit-bangged FTDI port This runs as a web server, connect to port 8008
Change HTTP_PORT for different port number or supply alternate as args[1]
- Requires:
- pylibftdi
-
class
pylibftdi.examples.bit_server.
ReqHandler
(request, client_address, server)[source]¶ Bases:
BaseHTTPServer.BaseHTTPRequestHandler
lcd
Module¶
Write a string (argv[1] if run from command line) to a HD44780 LCD module connected via a FTDI UM232R/245R module using pylibftdi
example usage:
# while true; > do python lcd.py $( awk ‘{print $1}’ /proc/loadavg); > sleep 5; > done
Copyright (c) 2010-2014 Ben Bass <benbass@codedstructure.net> All rights reserved.
-
class
pylibftdi.examples.lcd.
LCD
(device)[source]¶ Bases:
object
- The UM232R/245R is wired to the LCD as follows:
- DB0..3 to LCD D4..D7 (pin 11..pin 14) DB6 to LCD ‘RS’ (pin 4) DB7 to LCD ‘E’ (pin 6)
led_flash
Module¶
Flash an LED connected via a FTDI UM232R/245R module using pylibftdi
Optionally supply a flash rate (in Hz, default 1) as an argument
Copyright (c) 2010-2014 Ben Bass <benbass@codedstructure.net> All rights reserved.
list_devices
Module¶
Report connected FTDI devices. This may be useful in obtaining serial numbers to use as the device_id parameter of the Device() constructor to communicate with a specific device when more than one is present.
example usage:
$ python pylibftdi/examples/list_devices.py FTDI:UB232R:FTAS1UN5 FTDI:UM232R USB <-> Serial:FTE4FFVQ
To open a device specifically to communicate with the second of these devices, the following would be used:
>>> from pylibftdi import Device
>>> dev = Device(device_id="FTE4FFVQ")
>>>
Copyright (c) 2011-2014 Ben Bass <benbass@codedstructure.net> All rights reserved.
magic_candle
Module¶
- Magic Candle - light falling on the LDR turns on the LED, which due
- to arrangement keeps the LED on until LDR/LED path is blocked
LDR (via a transistor switch - dark = ‘1’) - D0 LED (via series resistor) - D1
pylibftdi - codedstructure 2013-2014
midi_output
Module¶
-
class
pylibftdi.examples.midi_output.
MidiDevice
(*o, **k)[source]¶ Bases:
pylibftdi.device.Device
pin_read
Module¶
Display values on input pins of a BitBangDevice.
- TODO:
- ANSI colours / display differences in bold
- example - beep on pin 1 going high:
- $ pylibftdi/examples/pin_read.py -n 0.01 -m 1 -k 1 && beep
Copyright (c) 2011-2014 Ben Bass <benbass@codedstructure.net> All rights reserved.
-
pylibftdi.examples.pin_read.
display_loop
(interval=1, count=0, match=None, mask=255)[source]¶ display and compare the value
Parameters: - interval – polling interval in seconds
- count – number of polls to do, or infinite if 0
- match – value to look for to exit early
- mask – mask of read value before comparing to match
Returns: ‘ok’. either a match was made or none was requested
Return type: bool
serial_loopback
Module¶
test serial loopback; assumes Rx and Tx are connected
Copyright (c) 2010-2014 Ben Bass <benbass@codedstructure.net> All rights reserved.