lukaspalm / rocklib

A universal library in python for the Radxa PCBs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rocklib

A universal python library for GPIO control using Radxa PCBs.

Note

Version 1.0 is almost here!
This will include pin toggle, and reading pin input values (Read was moved to Version 2.0, as it is deprecated on the SYSfs interface), with support for all Rock 4-Series models. This will use the SYSfs innerface.
If you want your device to be next, contact me and I will make sure to add it to the next version!


Important

For any bugs found, please open an issue here on github.
Optionally, contact me by pinging @lukaspalm in the radxa discord server, or by sending a DM on discord.

Features and Supported Devices

πŸ”΄ - Not started
🟑 - Work in progress
🟒 - Done and ready to use

 

X-Series

Feature/Device X2L
Pinouts 🟑
16x2 LCD Display πŸ”΄
Individual pin on/off πŸ”΄
Individual pin read input πŸ”΄
Servo-Motor πŸ”΄
Stepper-Motor πŸ”΄
Motion Detector πŸ”΄
Keypad (link) πŸ”΄
Ultrasonic Sensor (HC-SR04) πŸ”΄

 

E-Series

Feature/Device Rock Pi E
Pinouts 🟑
16x2 LCD Display πŸ”΄
Individual pin on/off πŸ”΄
Individual pin read input πŸ”΄
Servo-Motor πŸ”΄
Stepper-Motor πŸ”΄
Motion Detector πŸ”΄
Keypad (link) πŸ”΄
Ultrasonic Sensor (HC-SR04) πŸ”΄

 

Zero-Series

Feature/Device Zero Zero 2 Pro Zero 3E Zero 3W
Pinouts 🟑 🟑 🟑 🟑
16x2 LCD Display πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄
Individual pin on/off πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄
Individual pin read input πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄
Servo-Motor πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄
Stepper-Motor πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄
Motion Detector πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄
Keypad (link) πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄
Ultrasonic Sensor (HC-SR04) πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄

 

Rock S-Series

Feature/Device Rock Pi S Rock S0
Pinouts 🟑 🟑
16x2 LCD Display πŸ”΄ πŸ”΄
Individual pin on/off πŸ”΄ πŸ”΄
Individual pin read input πŸ”΄ πŸ”΄
Servo-Motor πŸ”΄ πŸ”΄
Stepper-Motor πŸ”΄ πŸ”΄
Motion Detector πŸ”΄ πŸ”΄
Keypad (link) πŸ”΄ πŸ”΄
Ultrasonic Sensor (HC-SR04) πŸ”΄ πŸ”΄

 

Rock 3-Series

Feature/Device Rock 3A Rock 3B Rock 3C
Pinouts 🟑 🟑 🟑
Camera RPI v1.3 🟒 N/A 🟒
16x2 LCD Display πŸ”΄ πŸ”΄ πŸ”΄
Individual pin on/off πŸ”΄ πŸ”΄ πŸ”΄
Individual pin read input πŸ”΄ πŸ”΄ πŸ”΄
Servo-Motor πŸ”΄ πŸ”΄ πŸ”΄
Stepper-Motor πŸ”΄ πŸ”΄ πŸ”΄
Motion Detector πŸ”΄ πŸ”΄ πŸ”΄
Keypad (link) πŸ”΄ πŸ”΄ πŸ”΄
Ultrasonic Sensor (HC-SR04) πŸ”΄ πŸ”΄ πŸ”΄

 

Rock 4-Series

Feature/Device Rock 4SE Rock 4A Rock 4A+ Rock 4B Rock 4B+ Rock 4C+
Pinouts 🟒 🟒 🟒 🟒 🟒 🟒
Camera RPI v1.3 🟒 🟒 🟒 🟒 🟒 N/A
16x2 LCD Display 🟑 🟑 🟑 🟑 🟑 🟑
Individual pin on/off 🟒 🟒 🟒 🟒 🟒 🟒
Individual pin read input 🟑 🟑 🟑 🟑 🟑 🟑
Servo-Motor πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄
Stepper-Motor πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄
Motion Detector πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄
Keypad (link) πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄
Ultrasonic Sensor (HC-SR04) πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄ πŸ”΄

 

Rock 5-Series

Feature/Device Rock 5A Rock 5B
Pinouts 🟑 🟑
16x2 LCD Display πŸ”΄ πŸ”΄
Individual pin on/off πŸ”΄ πŸ”΄
Individual pin read input πŸ”΄ πŸ”΄
Servo-Motor πŸ”΄ πŸ”΄
Stepper-Motor πŸ”΄ πŸ”΄
Motion Detector πŸ”΄ πŸ”΄
Keypad (link) πŸ”΄ πŸ”΄
Ultrasonic Sensor (HC-SR04) πŸ”΄ πŸ”΄

 

Installation

Warning

This library does not yet exist on pypi, as this is a work in progress.
The code may not be complete. Wait for release, or do debugging yourself.

You will need python3-dev, on Debian/Ubuntu. You can install this with:

sudo apt install python3-dev

Use the package manager pip to install rocklib.

pip install rocklib

Usage

Camera
from rocklib import camera

# Replace picture.png with your outfile name  
# Replace /dev/video0 with your video device

camera.takePicture(out="picture.jpg", device="/dev/video0")

Pin Toggle
from rocklib import pins, pinouts

# Example for Rock Pi 4-Series
# Initialize the GPIO pinout for Rock 4-series
pins.initialize(pinouts.ROCK4)

# Set pin 22 to value 1. Now pin 22 will be HIGH
pins.setPin(22, 1)

# Set pin 22 to value 0. Now pin 22 will be LOW
pins.setPin(22, 0)

More coming soon...

 

TODO

  • Pinouts for all versions
  • Pin-control without depending on gpiod
  • Finding members of the community for testing on new versions
  • Pin control with SYSfs innerface

 

Contributing

You can wish devices that I will add support for, if it does not already exist. View the list of supported devices.

Contact me by pinging me in the Radxa discord server @lukaspalm, or by sending me a DM on discord.

License

MIT

About

A universal library in python for the Radxa PCBs.

License:MIT License


Languages

Language:Python 100.0%