TroykaHatPython
Raspberry Pi library for interaction with a Amperka TroykaHAT.
Enabled I²C Interface
If you haven’t enabled I²C support in your Raspbian Linux yet, open the terminal and run the following commands:
- Run
sudo raspi-config. - Use the down arrow to select Interfacing Options.
- Arrow down to I²C.
- Select <Yes> when it asks you to enable I²C.
- Press <Ok> when it tells you that I²C is enabled.
- Use the right arrow to select the <Finish> button.
- Reboot your Raspberry Pi to make the I²C interface appear.
After the reboot, log in and enter the following command:
$ ls /dev/i2c*
The Pi should respond with:
/dev/i2c-1
This means that the I²C is on.
Testing I²C Device Connection
For testing connection Troyka HAT board to Raspberry Pi, useful package I²C scanner.
Install the I²C scanner.
sudo apt-get install i2c-tools
Turn it on.
sudo i2cdetect -y 1
In response, Raspberry Pi will show the addresses of all connected I²C devices. Check if the 0x2A address is present.
Installation Library
Use pip to install the library:
pip3 install troykahat
Quickstart example
import troykahat
from time import sleep
# Constant for Pin 7 of Wiring PI IO.
# Connect an LED to this pin.
PIN_WP_LED = 7
# Constant for Pin 7 of Analog PI IO.
# Connect an LED to this pin.
PIN_AP_LED = 7
# Gives access to all the functions of GPIO, that are labeled "Wiring PI IO" on the HAT.
# Check WiringPI library API (https://github.com/WiringPi/WiringPi-Python)
# for the functions reference.
wp = troykahat.wiringpi_io()
# Gives access to all the functions of GPIO, that are labeled "Analog IO" on the HAT.
# Check API.md for the functions reference.
ap = troykahat.analog_io()
# Configures the LED pin of Wiring PI IO to an output mode.
wp.pinMode(PIN_WP_LED, wp.OUTPUT)
# Configures the LED pin of Analog IO to an output mode.
ap.pinMode(PIN_AP_LED, ap.OUTPUT)
while True:
# Sets HIGH voltage level for the LED pin of Wiring PI IO.
wp.digitalWrite(PIN_WP_LED, True)
# Sets HIGH voltage level for the LED pin of Analog IO.
ap.digitalWrite(PIN_AP_LED, True)
# Wait 500 ms.
sleep(0.5)
# Sets HIGH voltage level for the LED pin of Wiring PI IO.
wp.digitalWrite(PIN_WP_LED, False)
# Sets HIGH voltage level for the LED pin of Analog IO.
ap.digitalWrite(PIN_AP_LED, False)
# Wait 500 ms.
sleep(0.5)
See full API reference in API.md
Metadata
Release files for troykahat 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| troykahat-1.0.0.tar.gz | 17.4 kB | Without provenance | Details |
Release files / troykahat-1.0.0.tar.gz
| Download URL | troykahat-1.0.0.tar.gz |
|---|---|
| Size | 17.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
26f50313baad2d342597fcfc8db60cb11773e3e53a5789afcf4a71fd24ae1822
|
|
BLAKE2b-256 checksum How to use checksums |
bbcedf57c55772ff3d65058a54ede06c6e6df25da8de5d76f3f1235dee8e174e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
|
Security for troykahat 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.