The Plumbing library.
PROCs in this module generally have arguments in this order:
- non-channels;
- input channels;
- output channels.
Index
-
Process
adc- Read an analog value -
Process
blink- Drives a pin alternately LOW and HIGH on a fixed cycle -
Process
button.press- Watches for button presses on pin 2 or 3 -
Process
clamp- Limits the range of values in a stream -
Process
debounce- Debounce a channel -
Process
digital.input- Read digital levels on pin 2 or 3 -
Process
digital.output- Set digital levels on a pin -
Process
heartbeat- A parallel health monitor -
Process
invert.level- Invert LEVELs -
Process
level.to.signal- Convert a LEVEL to a SIGNAL -
Process
pin.toggle- Drives a pin alternately LOW and HIGH -
Process
pwm- Writes an analog value to a pin -
Process
tick- Generates a consistent stream of SIGNALs -
Process
toggle- Outputs an alternating stream of LEVEL values
Declarations
plumbing.module:30Process digital.output
PROC digital.output (VAL INT pin, CHAN LEVEL in?)
Set digital levels on a pin. Reads LEVEL values (LOW or HIGH) on the input channel, and sets the value of the specified pin accordingly.
Parameters:
VAL INT |
pin |
The Arduino pin number |
CHAN LEVEL |
in |
Pin levels (LOW or HIGH) |
plumbing.module:48Process digital.input
PROC digital.input (VAL INT pin, CHAN LEVEL out!)
Read digital levels on pin 2 or 3. For only pin 2 or pin 3 on the Arduino, this procedure will output a LEVEL (either LOW or HIGH) whenever the pin changes value.
Parameters:
VAL INT |
pin |
The Arduino pin number (2 or 3 only) |
CHAN LEVEL |
out |
The LEVEL, output when the pin changes level. |
plumbing.module:97Process debounce
PROC debounce (CHAN LEVEL in?, out!)
Debounce a channel. Debounces a channel of LEVELs. Specifically, if multiple values come in within the DEBOUNCE.TIME (currently 50ms), only the first value is passed through.
Parameters:
CHAN LEVEL |
in |
The incoming LEVEL values |
CHAN LEVEL |
out |
The outgoing LEVEL values, debounced |
plumbing.module:124Process level.to.signal
PROC level.to.signal (CHAN LEVEL in?, CHAN SIGNAL out!)
Convert a LEVEL to a SIGNAL. Consumes a stream of LEVEL values, and emits a SIGNAL for each LEVEL received, regardless of whether it is LOW or HIGH.
Parameters:
CHAN LEVEL |
in |
Input LEVEL values. |
CHAN SIGNAL |
out |
Output SIGNALs. |
plumbing.module:138Process invert.level
PROC invert.level (CHAN LEVEL in?, out!)
Invert LEVELs. Reads in LEVEL values, and outputs the opposite. Upon receiving a LOW, sends a HIGH, and visa versa.
Parameters:
CHAN LEVEL |
in |
Incoming LEVEL values. |
CHAN LEVEL |
out |
Outgoing LEVEL values, inverted. |
plumbing.module:166Process tick
PROC tick (VAL INT period, CHAN SIGNAL out!)
Generates a consistent stream of SIGNALs. Every period milliseconds, a SIGNAL is generated.
Parameters:
VAL INT |
period |
A delay time in milliseconds. |
CHAN SIGNAL |
out |
SIGNALs generated after the given delay. |
plumbing.module:181Process toggle
PROC toggle (VAL LEVEL initial.level, CHAN SIGNAL in?, CHAN LEVEL out!)
Outputs an alternating stream of LEVEL values. Starting with an initial level (either LOW or HIGH), this process outputs a stream of alternating LEVEL values upon request. On receiving a SIGNAL, the next LEVEL is emitted
Parameters:
VAL LEVEL |
initial.level |
Either LOW or HIGH to start. |
CHAN SIGNAL |
in |
The request line. |
CHAN LEVEL |
out |
The alternating stream of LEVEL values. |
plumbing.module:196Process pin.toggle
PROC pin.toggle (VAL INT pin, VAL LEVEL initial.level, CHAN SIGNAL in?)
Drives a pin alternately LOW and HIGH. Upon request, alternates the level of a pin from LOW to HIGH.
Parameters:
VAL INT |
pin |
The (digital) Arduino pin we want to drive. |
VAL LEVEL |
initial.level |
Either LOW or HIGH. |
CHAN SIGNAL |
in |
The request line. |
plumbing.module:208Process blink
PROC blink (VAL INT pin, delay.time)
Drives a pin alternately LOW and HIGH on a fixed cycle. Every delay.time milliseconds, toggles a pin.
Parameters:
VAL INT |
pin |
The Arduino pin. |
VAL INT |
delay.time |
The number of milliseconds between toggles. |
plumbing.module:217Process heartbeat
PROC heartbeat ()
A parallel health monitor. Blinks the LED.PIN (or pin 13) on the Arduino every 500 ms.
plumbing.module:230Process clamp
PROC clamp (VAL INT low, high, CHAN INT in?, out!)
Limits the range of values in a stream. Takes a low and high limit, and any integers read in that are below the 'low' value are clamped to low, and likewise with the 'high' value.
Parameters:
VAL INT |
low |
The lower limit for valid numbers. |
VAL INT |
high |
The upper limit for valid numbers. |
CHAN INT |
in |
The input stream of INTs. |
CHAN INT |
out |
The output stream of INTs. |
plumbing.module:252Process pwm
PROC pwm (VAL INT pin, CHAN INT level?)
Writes an analog value to a pin. For a given (analog) pin, sets the level to a value between 0 and 255. Negative values are treated as 0, and values greater than 255 are treated as 255.
Parameters:
VAL INT |
pin |
The Arduino pin number |
CHAN INT |
level |
The input level. |
plumbing.module:277Process adc
PROC adc (VAL INT pin, CHAN SIGNAL req?, CHAN INT val!)
Read an analog value. For the given pin, will do an analog read of that pin and emit the value upon request. Currently not parallel safe.
Parameters:
VAL INT |
pin |
The Arduino pin number |
CHAN SIGNAL |
req |
The request line. |
CHAN INT |
val |
The current analog reading, 0 - 1023 |
