Pelican protects what's valuable. Cases, coolers, phone cases, flashlights, travel gear, luggage, drinkware, and backpacks. Pelican products, made in USA. From polyglotturtle import PolyglotTurtleXiao pt = PolyglotTurtleXiao(serialnumber='9B1ECC342E3120FF02110D') All devices have a unique serial number that is associated with the USB device. You can find this number in Windows using Device Manager, in Mac OS using System Report, and in Linux using lsusb. Type ppm install Polyglot Perl 5.8 Perl 5.10 Perl 5.12 Perl 5.14 Perl 5.16 Perl 5.18 Perl 5.20 Perl 5.22. Mac OS X: 0.14 0.14: Available View build log.
Latest versionReleased:
A python driver for the polyglot-turtle firmware
This repository contains a python library for communicating with the polyglot-turtle firmware. It has been tested to work on Windows, Mac and Linux.
To install, run
Only python 3.6+ is supported. This driver does not expose any USB-to-serial functionality, for that you should use something like pyserial.
This library depends on cython-hidapi which requires you to install some extra binary dependencies. On Ubuntu (tested on 18.04), you can install these dependencies using the following command:
By default, Linux does not allow access to USB or HID devices for a non-root user. To give access to your own user is simple. First, in /etc/udev/rules.d
, create a new file called 00-polyglot-turtle.rules
and paste the following two lines in:
This will give access to any user in the plugdev
group. Now, just add yourself to the group:
(you need to replace <your username>
with your actual username on your computer).
Once this is done, reboot and everything should work.
Almost all code using this library will need two lines:
The first line imports the main class from the library, and the second line connects to the device. After that, you simply use the pt
object to interact with your device.
You can connect to a specific device using its serial number if more than one is present:
All devices have a unique serial number that is associated with the USB device. You can find this number in Windows using Device Manager, in Mac OS using System Report, and in Linux using lsusb
.
There are 4 GPIO pins on the polyglot-turtle-xiao numbered 0-3. All four of these pins can be used as a digital input or output by setting the pin direction:
To read from an input or write to an output, use the gpio_set_level
and gpio_get_level
functions respectively:
When using a pin as an input, you can additionally enable a weak internal pullup or pulldown resistor:
To use the SPI interface, connect one of the GPIO pins to the CS pin of your target device, and otherwise connect MISO, MOSI and SCK as usual.
The polyglot-turtle firmware supports a single SPI operation, called 'exchange'. This can be used to interact with any SPI device, and even some non-SPI devices too! In an exchange operation, the polyglot-turtle firmware will write all of the bytes provided to the target device, and return all of the bytes read back from the device. As SPI requires the device to shift out one byte for every byte shifted in, you will receive the same number of bytes that was written.
An SPI exchange requires you to send the following parameters to the device:
Almost all I2C transactions can be broken down into combinations of three operations:
The polyglot-turtle firmware supports all three of these operations using a single function, i2c_exchange
. This function takes the following arguments:
The type of operation is selected simply by the number of bytes provided to write, and the number of bytes requested to read.
See below for some examples:
Since the I2C standard only allows three specific clock rates, the polyglot-turtle firmware also only supports these three speeds:
STANDARD
: 100kHzFAST
: 400kHzFAST_PLUS
: 1MHzThere are some simple examples in the git repository you can look at for more information.
0.0.4
0.0.3
0.0.2
0.0.1
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size polyglot_turtle-0.0.4-py3-none-any.whl (8.0 kB) | File type Wheel | Python version py3 | Upload date | Hashes |
Filename, size polyglot-turtle-0.0.4.tar.gz (6.5 kB) | File type Source | Python version None | Upload date | Hashes |
Algorithm | Hash digest |
---|---|
SHA256 | f0d22973e1a5180348315925e57f0693b4c9993fa3b08a783eedfdd3fba79ab0 |
MD5 | 4df968ea3dad481def0f5051c588b95f |
BLAKE2-256 | 86e212ea803779568c88199a280947e5b6e20b3d7270ce660e89b9ac92d0ec7a |
Algorithm | Hash digest |
---|---|
SHA256 | 8484559ff8ba7fc33c8c73f80ea6e6ebf111246fba2634163859c5f4f44cede5 |
MD5 | 58b6c222936ab4e4cefeff9a63d8837c |
BLAKE2-256 | 009dce7c2c247b6e2fac38fa016e676b29b3062483dc8712504ede563f6c4dc4 |