All Projects → tokafish → pigpiox

tokafish / pigpiox

Licence: Apache-2.0 License
An Elixir wrapper around pigpiod for the Raspberry PI

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to pigpiox

Nerves
Craft and deploy bulletproof embedded software in Elixir
Stars: ✭ 1,778 (+6031.03%)
Mutual labels:  embedded, nerves
houseflow
Home automation platform for microcontrollers(including ESP8266/ESP32), Raspberry Pi, and others. Made with Rust and C++.
Stars: ✭ 88 (+203.45%)
Mutual labels:  embedded
epsilon-sample-app-rust
A sample Rust app for the NumWorks graphing calculator
Stars: ✭ 16 (-44.83%)
Mutual labels:  embedded
diy-linux-guide
An LFS like guide for cross-bootstrapping a small system for the Raspberry Pi
Stars: ✭ 26 (-10.34%)
Mutual labels:  embedded
gdbstub
An ergonomic and easy-to-integrate implementation of the GDB Remote Serial Protocol in Rust, with full no_std support.
Stars: ✭ 158 (+444.83%)
Mutual labels:  embedded
esm
Lightweight communicating state machine framework for embedded systems
Stars: ✭ 21 (-27.59%)
Mutual labels:  embedded
pwm-pca9685-rs
Platform-agnostic Rust driver for the PCA9685 I2C 16-channel, 12-bit PWM/Servo/LED controller
Stars: ✭ 19 (-34.48%)
Mutual labels:  embedded
littlefs2
Idiomatic Rust API for littlefs
Stars: ✭ 19 (-34.48%)
Mutual labels:  embedded
kiwi
Kiwi turns your Pimoroni Keybow into a fully customizable poor-man's Elgato Stream Deck!
Stars: ✭ 40 (+37.93%)
Mutual labels:  nerves
mikroe-uhb
USB HID Bootloader programming tool for devices manufactured by MikroElektronika
Stars: ✭ 15 (-48.28%)
Mutual labels:  embedded
drone-cortexm
ARM® Cortex®-M platform crate for Drone, an Embedded Operating System.
Stars: ✭ 31 (+6.9%)
Mutual labels:  embedded
tutorials
Tutorials written by me.
Stars: ✭ 17 (-41.38%)
Mutual labels:  embedded
awesome-automotive-can-id
🚜 unpretentious attempt to collect CAN IDs and payloads for various car brands/models in one place.
Stars: ✭ 104 (+258.62%)
Mutual labels:  embedded
libpicrin
Super Tiny Scheme Interpreter for Freestanding Environment
Stars: ✭ 54 (+86.21%)
Mutual labels:  embedded
NMSIS
Nuclei Microcontroller Software Interface Standard Development Repo
Stars: ✭ 24 (-17.24%)
Mutual labels:  embedded
cortex-uni-startup
Unified startup code and link scripts for Cortex-M microcontrollers
Stars: ✭ 33 (+13.79%)
Mutual labels:  embedded
hruby
Embed Ruby in your Haskell program.
Stars: ✭ 22 (-24.14%)
Mutual labels:  embedded
o1heap
Constant-complexity deterministic memory allocator (heap) for hard real-time high-integrity embedded systems
Stars: ✭ 119 (+310.34%)
Mutual labels:  embedded
async
🔀 Asynchronous framework in C.
Stars: ✭ 16 (-44.83%)
Mutual labels:  embedded
InfiniTime
Firmware for Pinetime smartwatch written in C/C++ and based on FreeRTOS
Stars: ✭ 1,303 (+4393.1%)
Mutual labels:  embedded

Pigpiox

Pigpiox is a wrapper around pigpiod for the Raspberry Pi. For all of pigpio's features, check out its documentation.

Requirements

To use Pigpiox, pigpiod must be included in your firmware. Currently, this is included by default on nerves_system_rpi0, but not on other Pi systems.

If you'd like to use Pigpiox on one of those systems, customize the nerves system you're interested in, and add BR2_PACKAGE_PIGPIO=y to its nerves_defconfig.

Installation

In your firmware's mix.exs, add pigpiox to your deps for your system target:

def deps(target) do
  [ system(target),
    {:pigpiox, "~> 0.1"}
  ]

Usage

Adding pigpiox as a dependency to your system will automatically launch the pigpio daemon and open a socket to communicate with it. To interact with pigpiod, Pigpiox provides various modules exposing different areas of functionality.

All documentation available on hexdocs.

GPIO

Basic functionality

The Pigpiox.GPIO provides basic GPIO functionality. Here's an example of reading and writing a GPIO:

gpio = 17

Pigpiox.GPIO.set_mode(gpio, :input)
{:ok, level} = Pigpiox.GPIO.read(gpio)

Pigpiox.GPIO.set_mode(gpio, :output)
Pigpiox.GPIO.write(gpio, 1)

Watching a GPIO

When reading a GPIO, often it's useful to know immediately when its level changes, instead of having to constantly poll it. Here's an example:

{:ok, pid} = Pigpiox.GPIO.watch(gpio)

After setting up a watch on a GPIO pin, the calling process will receive messages of the format {:gpio_leveL_change, gpio, level} as its level change.

Waveforms

The Pigpiox.Waveform module provides functions that allow you to create and send waveforms on the Raspberry Pi. Here's an example of pulsing a GPIO on and off every 500ms:

pulses = [
  %Pigpiox.Waveform.Pulse{gpio_on: gpio, delay: 500000},
  %Pigpiox.Waveform.Pulse{gpio_off: gpio, delay: 500000}
]

Pigpiox.Waveform.add_generic(pulses)

{:ok, wave_id} = Pigpiox.Waveform.create()

Pigpiox.GPIO.set_mode(gpio, :output)

Pigpiox.Waveform.repeat(wave_id)

Clock

The Pigpiox.Clock module provides functions that allow you to set a clock on reserved pin.

Pigpiox.Clock.hardware_clk(gpio, 2_500_000)

Pulse-width modulation (PWM)

The Pigpiox.Pwm module provides functions that allow you to build and send waveforms with pigpiod. According to Raspberry Pi's GPIO usage documentation, here are the pins PWM is avaliable on:

  • Software PWM: all pins
  • Hardware PWM: GPIO12, GPIO13, GPIO18, GPIO19

Software PWM

Max value for level is 255. Here's an example of changing the brightness of an LED using software PWM.

gpio = 12
Pigpiox.Pwm.gpio_pwm(gpio, 255) # 100%
Pigpiox.Pwm.gpio_pwm(gpio, 127) # 50%
Pigpiox.Pwm.gpio_pwm(gpio, 25)  # 10%
Pigpiox.Pwm.gpio_pwm(gpio, 2)   # 1%

Hardware PWM

Max value for level is 1_000_000. Here's an example of changing the brightness of an LED using hardware PWM.

gpio = 12
frequency = 800
Pigpiox.Pwm.hardware_pwm(gpio, frequency, 1_000_000) # 100%
Pigpiox.Pwm.hardware_pwm(gpio, frequency, 500_000)   # 50%
Pigpiox.Pwm.hardware_pwm(gpio, frequency, 100_000)   # 10%
Pigpiox.Pwm.hardware_pwm(gpio, frequency, 10_000)    # 1%

Contributions

This library is still in a very early stage, and I'd appreciate any and all contributions. In particular, a short-term goal is getting feature parity with the python pigpiod client library.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].