All Projects → helins → linux.gpio.clj

helins / linux.gpio.clj

Licence: EPL-1.0 license
Use the standard Linux GPIO API from Clojure JVM

Programming Languages

clojure
4091 projects
shell
77523 projects

Projects that are alternatives of or similar to linux.gpio.clj

gpioctl
Control the ALSA mixer or generate JACK MIDI or OSC messages from rotary encoders and switches connected to GPIOs.
Stars: ✭ 18 (-25%)
Mutual labels:  gpio
darkseer
Experimental JVM profiler for analyzing real-world memory allocations
Stars: ✭ 13 (-45.83%)
Mutual labels:  jvm
JVMByPython
《自己动手写Java虚拟机》JVM的python实现
Stars: ✭ 110 (+358.33%)
Mutual labels:  jvm
ows4R
R Interface for OGC Web-Services (OWS)
Stars: ✭ 29 (+20.83%)
Mutual labels:  standard
turtle
Run shell commands from a Kotlin script or application with ease
Stars: ✭ 128 (+433.33%)
Mutual labels:  jvm
kdl4j
KDL Parser for the JVM
Stars: ✭ 16 (-33.33%)
Mutual labels:  jvm
pikt
🎨 Image-based poetic programming language.
Stars: ✭ 72 (+200%)
Mutual labels:  jvm
gsclib
gsclib acts as a standard library extension for the Call of Duty 4 scripting language.
Stars: ✭ 32 (+33.33%)
Mutual labels:  standard
gctoolkit
Tool for parsing GC logs
Stars: ✭ 1,127 (+4595.83%)
Mutual labels:  jvm
HPlayer2
Modular Media Player for Raspberry Pi and more...
Stars: ✭ 28 (+16.67%)
Mutual labels:  gpio
nebuchadnezzar
on the way to cleanest react architechture
Stars: ✭ 15 (-37.5%)
Mutual labels:  standard
2p-kt
A Kotlin Multi-Platform ecosystem for symbolic AI
Stars: ✭ 52 (+116.67%)
Mutual labels:  jvm
review-notes
团队分享学习、复盘笔记资料共享。Java、Scala、Flink...
Stars: ✭ 27 (+12.5%)
Mutual labels:  jvm
python3-gpiod
gpiod pure Python library with almost the same usage as libgpiodcxx
Stars: ✭ 28 (+16.67%)
Mutual labels:  gpio
storage
Storage Standard
Stars: ✭ 92 (+283.33%)
Mutual labels:  standard
infra
Infra Standard
Stars: ✭ 85 (+254.17%)
Mutual labels:  standard
play-scala-streaming-example
Example Play application showing Comet and Server Sent Events in Scala
Stars: ✭ 42 (+75%)
Mutual labels:  jvm
gpio
A RaspberryPi GPIO library written in PHP.
Stars: ✭ 16 (-33.33%)
Mutual labels:  gpio
SevenFacette
7Facette is an open-source multiplatform test automation library supporting JVM and JS.
Stars: ✭ 28 (+16.67%)
Mutual labels:  jvm
rxjava2-http
Transmit RxJava2 Flowable over http with non-blocking backpressure
Stars: ✭ 19 (-20.83%)
Mutual labels:  jvm

Linux.GPIO

Clojars Project

cljdoc badge

Handle GPIO lines in a fast and portable way from Clojure.

Based on linux-gpio.java. Go there for rationale and background.

In short, this API controls GPIO devices from user space by using the "new" Linux API which is convenient, standard, and offers some advantages over other methods (eg. automatic clean-up of resources when lines are released).

A GPIO device is a driver located in "/dev". For instance, on the Raspbian operating system running on a Raspberry Pi, one can control all GPIO lines by using the "/dev/gpiochip0" GPIO device.

Compatible with Linux 4.8 and higher, tested on the Raspberry Pi 3.

Usage

This is a very brief overview.

The full API is available on Cljdoc.

Small examples are available in the helins.linux.gpio.example.

Attention, at least read permission is needed for the used GPIO devices, which is enough even for writing to outputs.

For instance :

(require '[helins.linux.gpio :as gpio])


;; Alternating between 2 leds every time a button is released.
;;
;; After opening a GPIO device, we need a handle for driving the leds and a watcher
;; for monitoring the button. A buffer is used in conjunction with the handle in
;; order to describe the state of the leds.


(with-open [device         (gpio/device "/dev/gpiochip0")
            led-handle     (gpio/handle device
                                        {17 {:gpio/state false
                                             :gpio/tag   :led-1}
                                         18 {:gpio/state true
                                             :gpio/tag   :led-2}}
                                        {:gpio/direction :output})
            button-watcher (gpio/watcher device
                                         {22 {:gpio/direction :input}})]
  (let [buffer (gpio/buffer led-handle)]
    (loop [leds (cycle [:led-1
                        :led-2])]
      (gpio/write led-handle
                  (gpio/set-line+ buffer
                                  {(first  leds) true
                                   (second leds) false}))
      (gpio/event button-watcher)
      (recur (rest leds)))))

License

Copyright © 2018 Adam Helinski

Licensed under the term of the Mozilla Public License 2.0, see LICENSE.

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].