nightseas / python-nightWiring

Python wrap of nightWiring lib.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

python-nightWiring

Python wrap of nightWiring lib.

Idea

Refer to nightWiring (https://github.com/nightseas/nightWiring).

Advantage:

  • Python is an easier and more flexible way for end user to control peripherals.
  • To be a pythoner could protect you in the jungle. lol

Same as nightWiring, you need to create a GPIO map table if you want to use GPIO functions. For interfaces such as SPI or serial port, only device file name (bus number) is needed.

Installation

git clone https://github.com/nightseas/python-nightWiring
cd python-nightWiring

# Update C code from nightWiring
git submodule init && git submodule update

# Use sudo if permission denied
python setup.py install

Programming

# Import nightWiring.io (NOT nightWiring itself, and don't ask me why)
from nightWiring import io

from time import sleep

# Needed for GPIO map
from array import array

# A demo GPIO map for Raspberry Pi with ICA HAT, 'i' means integer.
ledMap = array('i', [27, 23, 22, 24])

# Setup nightWiring core function and GPIO function with our LED GPIO map.
io.setup()
io.setupGPIO(ledMap, 4)

# LED0 blink
io.pinMode(0, io.OUTPUT)

while True:
  io.digitalWrite(0, io.HIGH)
  sleep(0.5)
  io.digitalWrite(0, io.LOW)
  sleep(0.5)

Execute your program

python code_file_name.py

Refer to examples for details.

About

Python wrap of nightWiring lib.

License:GNU General Public License v3.0


Languages

Language:C 82.0%Language:Python 18.0%