This namespace provides utilities for opening a GPIO device in order to :
- Request some information (eg. about a line).
- Request a handle for driving one or several lines at once.
- Request a watcher for efficiently monitoring one or several lines.
A handle controls all the lines it is responsible for at once. Whether those lines are actually driven exactly at the same time, atomically, depends on the underlying driver and is opaque to this library.
A watcher is used essentially for interrupts. Requested events, such as a line transitioning from false to true, are queued by the kernel until read. However, Linux not being a real-time OS, such "interrupts" are imperfect and should not be used for critical tasks where a simple microcontroller will be of a better fit.
Lines are abstracted by associating a line number with a tag (ie. any value meant to be more representative of what the line does, often a keyword).
As usual, all IO functions might throw if anything goes wrong.
All functions and important concepts are specified with clojure.spec.
This namespace provides utilities for opening a GPIO device in order to : - Request some information (eg. about a line). - Request a handle for driving one or several lines at once. - Request a watcher for efficiently monitoring one or several lines. A handle controls all the lines it is responsible for at once. Whether those lines are actually driven exactly at the same time, atomically, depends on the underlying driver and is opaque to this library. A watcher is used essentially for interrupts. Requested events, such as a line transitioning from false to true, are queued by the kernel until read. However, Linux not being a real-time OS, such "interrupts" are imperfect and should not be used for critical tasks where a simple microcontroller will be of a better fit. Lines are abstracted by associating a line number with a tag (ie. any value meant to be more representative of what the line does, often a keyword). As usual, all IO functions might throw if anything goes wrong. All functions and important concepts are specified with clojure.spec.
(close resource)
Closes a GPIO resource such as a device or a handle.
Closes a GPIO resource such as a device or a handle.
Default values for argument options.
Default values for argument options.
(describe-chip device)
Requests a description of the given GPIO device.
Requests a description of the given GPIO device.
(describe-line device line-number)
Requests a description of the given line.
Requests a description of the given line.
(device device-path)
Opens a GPIO device either by specifying a full path or by giving the number of the device.
Read permission must be granted, which is enough even for writing to outputs.
Closing a GPIO device does not close related resources (ie. obtained handles and watchers).
Opens a GPIO device either by specifying a full path or by giving the number of the device. Read permission must be granted, which is enough even for writing to outputs. Closing a GPIO device does not close related resources (ie. obtained handles and watchers).
(handle device lines-number->line-options)
(handle device line-number->line-options handle-options)
Given a GPIO device, requests a handle for one or several lines which can then be used to read and/or write the state of lines.
Implements IHandle
.
Ex. (handle some-device {17 {::tag :red-led} 27 {::tag :green-led ::state true}} {::direction :output})
Given a GPIO device, requests a handle for one or several lines which can then be used to read and/or write the state of lines. Implements `IHandle`. Ex. (handle some-device {17 {::tag :red-led} 27 {::tag :green-led ::state true}} {::direction :output})
Controlling a GPIO buffer before or after doing some IO.
Ex. (write some-handle (-> some-buffer (clear-lines) (set-lines {:green-led true :red-led false})))
Controlling a GPIO buffer before or after doing some IO. Ex. (write some-handle (-> some-buffer (clear-lines) (set-lines {:green-led true :red-led false})))
(clear-lines buffer)
Sets all lines of the given buffer to false.
Sets all lines of the given buffer to false.
(get-line buffer tag)
Retrieves the state of a single line from the given buffer.
Retrieves the state of a single line from the given buffer.
(get-lines buffer)
(get-lines buffer tags)
Retrieves the state of several lines (or all of them if nothing is specified) from the given buffer.
Retrieves the state of several lines (or all of them if nothing is specified) from the given buffer.
(set-line buffer tag state)
Sets the state of a single line in the given buffer.
Sets the state of a single line in the given buffer.
(set-lines buffer tag->state)
Sets the state of several lines in the given buffer.
Sets the state of several lines in the given buffer.
(toggle-line buffer tag)
Toggles the state of a single line in the given buffer.
Toggles the state of a single line in the given buffer.
(toggle-lines buffer)
(toggle-lines buffer tags)
Toggles the state of several lines in the given buffer.
Toggles the state of several lines in the given buffer.
For objects that can work with a GPIO buffer.
For objects that can work with a GPIO buffer.
(buffer this)
Produces a GPIO buffer representing the state of up to 64 lines.
It implements IBuffer
and works with tags associated with this
.
It does not do any IO on its own as it is meant to be used in conjunction with a handle or a watcher.
Produces a GPIO buffer representing the state of up to 64 lines. It implements `IBuffer` and works with tags associated with `this`. It does not do any IO on its own as it is meant to be used in conjunction with a handle or a watcher.
IO using a GPIO handle and a buffer.
Reading or writing the state of lines happens virtually at once for all of them. Whether it happens exactly at the same time depends on the underlying driver and this fact is opaque. In any case, driving several lines using a single handle is more efficient than using a handle for each line.
IO using a GPIO handle and a buffer. Reading or writing the state of lines happens virtually at once for all of them. Whether it happens exactly at the same time depends on the underlying driver and this fact is opaque. In any case, driving several lines using a single handle is more efficient than using a handle for each line.
(read handle buffer)
Using a handle, reads the current state of lines into the given buffer.
Using a handle, reads the current state of lines into the given buffer.
(write handle buffer)
Using a handle, writes the current state of lines using the given buffer.
Using a handle, writes the current state of lines using the given buffer.
IO using a watcher.
IO using a watcher.
(event watcher)
(event watcher timeout-ms)
Using a watcher, efficiently blocks until the state of one of the monitored inputs switches to a relevant one or the timeout elapses.
A timeout of -1 will block forever until something happens.
Using a watcher, efficiently blocks until the state of one of the monitored inputs switches to a relevant one or the timeout elapses. A timeout of -1 will block forever until something happens.
(poll watcher buffer tag)
Using a watcher, reads the current state of a line.
Using a watcher, reads the current state of a line.
(watcher device line-number->watch-options)
Given a GPIO device, produces a watcher which can then be used to efficiently monitor inputs for changes or poll their current values.
Implements IWatcher
.
Ex. (watcher some-device {18 {::tag :left-button ::direction :input} 23 {::tag :right-button ::direction :output}})
Given a GPIO device, produces a watcher which can then be used to efficiently monitor inputs for changes or poll their current values. Implements `IWatcher`. Ex. (watcher some-device {18 {::tag :left-button ::direction :input} 23 {::tag :right-button ::direction :output}})
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close