Skip to content

Commit 44a9bdc

Browse files
authored
Merge pull request #7 from Ellipse0934/master
General fixes for 1.0
2 parents fa2790e + 7582323 commit 44a9bdc

11 files changed

+1940
-2868
lines changed

Manifest.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[[Sockets]]
2+
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

Project.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name = "PiGPIO"
2+
uuid = "bb151fc1-c6dc-5496-8ed6-07f94907e623"
3+
version = "0.1.0"
4+
5+
[deps]
6+
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"

README.md

+29-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,38 @@
44

55
[![PiGPIO](https://img.youtube.com/vi/UmSQjkaATk8/0.jpg)](https://www.youtube.com/watch?v=UmSQjkaATk8)
66

7-
## Installation and Usage
7+
PiGPIO.jl is a Julia package for the Raspberry which communicates with the pigpio
8+
daemon to allow control of the general purpose
9+
input outputs (GPIO).
10+
11+
This package is an effective translation of the python package for the same.
12+
Which can be found [here](http://abyz.me.uk/rpi/pigpio/python.html)
13+
14+
### Features
15+
16+
* OS independent. Only Julia 1.0+ required.
17+
* Controls one or more Pi's.
18+
* Hardware timed pulse width modulation.
19+
* Hardware timed servo pulse.
20+
* Callbacks when any of GPIO change state.
21+
* Create and transmit precise waveforms.
22+
* Read/Write GPIO and set their modes.
23+
* Wrappers for I2C, SPI, and serial links.
24+
25+
Once a pigpio daemon is launched on the pi this package can connect to
26+
it and communicate with it to manipulate the GPIO pins of the pi. The actual
27+
work is done by the daemon. One benefit of working this way is that you can
28+
remotely access the pi over a network and multiple instances can be connected
29+
to the daemon simultaneously.
830

9-
This package depends on the native [pigpio](http://abyz.co.uk/rpi/pigpio/index.html) control library, which is usually present in recent versions of raspbian. The `pigpiod` daemon must be started on the pi before using this package.
31+
Launching the daemon requires sudo privileges. Launch by typing `sudo pigpiod`
32+
in the terminal.
33+
34+
## Installation and Usage
1035

1136
```julia
12-
Pkg.clone("https://github.com/JuliaBerry/PiGPIO.jl")
37+
using Pkg
38+
Pkg.add("https://github.com/JuliaBerry/PiGPIO.jl")
1339

1440
using PiGPIO
1541

@@ -29,7 +55,4 @@ write(p, pin, state)
2955

3056
set_PWM_dutycycle(p, pin, dutycyle)
3157
#dutycyle defaults to a range 0-255
32-
3358
```
34-
35-

REQUIRE

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
julia 0.6
2-
StrPack
1+
julia 0.7

src/PiGPIO.jl

+6-268
Original file line numberDiff line numberDiff line change
@@ -1,276 +1,14 @@
1-
# """
2-
# pigpio is a Julia package for the Raspberry which talks to
3-
# the pigpio daemon to allow control of the general purpose
4-
# input outputs (GPIO).
5-
#
6-
# [http://abyz.co.uk/rpi/pigpio/python.html]
7-
#
8-
# *Features*
9-
#
10-
# o the pigpio Python module can run on Windows, Macs, or Linux
11-
#
12-
# o controls one or more Pi's
13-
#
14-
# o independent PWM on any of GPIO 0-31 simultaneously
15-
#
16-
# o independent servo pulses on any of GPIO 0-31 simultaneously
17-
#
18-
# o callbacks when any of GPIO 0-31 change state
19-
#
20-
# o creating and transmitting precisely timed waveforms
21-
#
22-
# o reading/writing GPIO and setting their modes
23-
#
24-
# o wrappers for I2C, SPI, and serial links
25-
#
26-
# o creating and running scripts on the pigpio daemon
27-
#
28-
# *GPIO*
29-
#
30-
# ALL GPIO are identified by their Broadcom number.
31-
#
32-
# *Notes*
33-
#
34-
# Transmitted waveforms are accurate to a microsecond.
35-
#
36-
# Callback level changes are time-stamped and will be
37-
# accurate to within a few microseconds.
38-
#
39-
# *Settings*
40-
#
41-
# A number of settings are determined when the pigpio daemon is started.
42-
#
43-
# o the sample rate (1, 2, 4, 5, 8, or 10 us, default 5 us).
44-
#
45-
# o the set of GPIO which may be updated (generally written to). The
46-
# end
47-
#
48-
# functionault set is those available on the Pi board revision.
49-
#
50-
# o the available PWM frequencies (see [*set_PWM_frequency*]).
51-
#
52-
# *Exceptions*
53-
#
54-
# By default a fatal exception is raised if you pass an invalid
55-
# argument to a pigpio function.
56-
#
57-
# If you wish to handle the returned status yourself you should set
58-
# pigpio.exceptions to false.
59-
#
60-
# You may prefer to check the returned status in only a few parts
61-
# of your code. In that case do the following.
62-
#
63-
# ...
64-
# pigpio.exceptions = false
65-
#
66-
# # Code where you want to test the error status.
67-
#
68-
# pigpio.exceptions = true
69-
# ...
70-
#
71-
# *Usage*
72-
#
73-
# This module uses the services of the C pigpio library. pigpio
74-
# must be running on the Pi(s) whose GPIO are to be manipulated.
75-
#
76-
# The normal way to start pigpio is as a daemon (during system
77-
# start).
78-
#
79-
# sudo pigpiod
80-
#
81-
# Your Python program must import pigpio and create one or more
82-
# instances of the pigpio.pi class. This class gives access to
83-
# a specified Pi's GPIO.
84-
#
85-
# ...
86-
# pi1 = pigpio.pi() # pi1 accesses the local Pi's GPIO
87-
# pi2 = pigpio.pi('tom') # pi2 accesses tom's GPIO
88-
# pi3 = pigpio.pi('dick') # pi3 accesses dick's GPIO
89-
#
90-
# pi1.write(4, 0) # set local Pi's GPIO 4 low
91-
# pi2.write(4, 1) # set tom's GPIO 4 to high
92-
# pi3.read(4) # get level of dick's GPIO 4
93-
# ...
94-
#
95-
# The later example code snippets assume that pi is an instance of
96-
# the pigpio.pi class.
97-
#
98-
# OVERVIEW
99-
#
100-
# Essential
101-
#
102-
# pigpio.pi Initialise Pi connection
103-
# stop Stop a Pi connection
104-
#
105-
# Beginner
106-
#
107-
# set_mode Set a GPIO mode
108-
# get_mode Get a GPIO mode
109-
# set_pull_up_down Set/clear GPIO pull up/down resistor
110-
#
111-
# read Read a GPIO
112-
# write Write a GPIO
113-
#
114-
# set_PWM_dutycycle Start/stop PWM pulses on a GPIO
115-
# get_PWM_dutycycle Get PWM dutycycle set on a GPIO
116-
#
117-
# set_servo_pulsewidth Start/Stop servo pulses on a GPIO
118-
# get_servo_pulsewidth Get servo pulsewidth set on a GPIO
119-
#
120-
# callback Create GPIO level change callback
121-
# wait_for_edge Wait for GPIO level change
122-
#
123-
# Intermediate
124-
#
125-
# gpio_trigger Send a trigger pulse to a GPIO
126-
#
127-
# set_watchdog Set a watchdog on a GPIO
128-
#
129-
# set_PWM_range Configure PWM range of a GPIO
130-
# get_PWM_range Get configured PWM range of a GPIO
131-
#
132-
# set_PWM_frequency Set PWM frequency of a GPIO
133-
# get_PWM_frequency Get PWM frequency of a GPIO
134-
#
135-
# read_bank_1 Read all bank 1 GPIO
136-
# read_bank_2 Read all bank 2 GPIO
137-
#
138-
# clear_bank_1 Clear selected GPIO in bank 1
139-
# clear_bank_2 Clear selected GPIO in bank 2
140-
#
141-
# set_bank_1 Set selected GPIO in bank 1
142-
# set_bank_2 Set selected GPIO in bank 2
143-
#
144-
# Advanced
145-
#
146-
# get_PWM_real_range Get underlying PWM range for a GPIO
147-
#
148-
# notify_open Request a notification handle
149-
# notify_begin Start notifications for selected GPIO
150-
# notify_pause Pause notifications
151-
# notify_close Close a notification
152-
#
153-
# bb_serial_read_open Open a GPIO for bit bang serial reads
154-
# bb_serial_read Read bit bang serial data from a GPIO
155-
# bb_serial_read_close Close a GPIO for bit bang serial reads
156-
# bb_serial_invert Invert serial logic (1 invert, 0 normal)
157-
#
158-
# hardware_clock Start hardware clock on supported GPIO
159-
# hardware_PWM Start hardware PWM on supported GPIO
160-
#
161-
# set_glitch_filter Set a glitch filter on a GPIO
162-
# set_noise_filter Set a noise filter on a GPIO
163-
#
164-
# Scripts
165-
#
166-
# store_script Store a script
167-
# run_script Run a stored script
168-
# script_status Get script status and parameters
169-
# stop_script Stop a running script
170-
# delete_script Delete a stored script
171-
#
172-
# Waves
173-
#
174-
# wave_clear Deletes all waveforms
175-
#
176-
# wave_add_new Starts a new waveform
177-
# wave_add_generic Adds a series of pulses to the waveform
178-
# wave_add_serial Adds serial data to the waveform
179-
#
180-
# wave_create Creates a waveform from added data
181-
# wave_delete Deletes a waveform
182-
#
183-
# wave_send_once Transmits a waveform once
184-
# wave_send_repeat Transmits a waveform repeatedly
185-
# wave_send_using_mode Transmits a waveform in the chosen mode
186-
#
187-
# wave_chain Transmits a chain of waveforms
188-
#
189-
# wave_tx_at Returns the current transmitting waveform
190-
# wave_tx_busy Checks to see if a waveform has ended
191-
# wave_tx_stop Aborts the current waveform
192-
#
193-
# wave_get_micros Length in microseconds of the current waveform
194-
# wave_get_max_micros Absolute maximum allowed micros
195-
# wave_get_pulses Length in pulses of the current waveform
196-
# wave_get_max_pulses Absolute maximum allowed pulses
197-
# wave_get_cbs Length in cbs of the current waveform
198-
# wave_get_max_cbs Absolute maximum allowed cbs
199-
#
200-
# I2C
201-
#
202-
# i2c_open Opens an I2C device
203-
# i2c_close Closes an I2C device
204-
#
205-
# i2c_write_quick SMBus write quick
206-
# i2c_write_byte SMBus write byte
207-
# i2c_read_byte SMBus read byte
208-
# i2c_write_byte_data SMBus write byte data
209-
# i2c_write_word_data SMBus write word data
210-
# i2c_read_byte_data SMBus read byte data
211-
# i2c_read_word_data SMBus read word data
212-
# i2c_process_call SMBus process call
213-
# i2c_write_block_data SMBus write block data
214-
# i2c_read_block_data SMBus read block data
215-
# i2c_block_process_call SMBus block process call
216-
#
217-
# i2c_read_i2c_block_data SMBus read I2C block data
218-
# i2c_write_i2c_block_data SMBus write I2C block data
219-
#
220-
# i2c_read_device Reads the raw I2C device
221-
# i2c_write_device Writes the raw I2C device
222-
#
223-
# i2c_zip Performs multiple I2C transactions
224-
#
225-
# bb_i2c_open Opens GPIO for bit banging I2C
226-
# bb_i2c_close Closes GPIO for bit banging I2C
227-
# bb_i2c_zip Performs multiple bit banged I2C transactions
228-
#
229-
# SPI
230-
#
231-
# spi_open Opens a SPI device
232-
# spi_close Closes a SPI device
233-
#
234-
# spi_read Reads bytes from a SPI device
235-
# spi_write Writes bytes to a SPI device
236-
# spi_xfer Transfers bytes with a SPI device
237-
#
238-
# Serial
239-
#
240-
# serial_open Opens a serial device (/dev/tty*)
241-
# serial_close Closes a serial device
242-
#
243-
# serial_read Reads bytes from a serial device
244-
# serial_read_byte Reads a byte from a serial device
245-
#
246-
# serial_write Writes bytes to a serial device
247-
# serial_write_byte Writes a byte to a serial device
248-
#
249-
# serial_data_available Returns number of bytes ready to be read
250-
#
251-
# CUSTOM
252-
#
253-
# custom_1 User custom function 1
254-
# custom_2 User custom function 2
255-
#
256-
# Utility
257-
#
258-
# get_current_tick Get current tick (microseconds)
259-
#
260-
# get_hardware_revision Get hardware revision
261-
# get_pigpio_version Get the pigpio version
262-
#
263-
# pigpio.error_text Gets error text from error number
264-
# pigpio.tickDiff Returns difference between two ticks
265-
# """
1+
# https://github.com/joan2937/pigpio/blob/master/pigpio.py
2662
module PiGPIO
2673

2684
export Pi
2695

270-
using StrPack
6+
using Sockets
2717

2728
include("constants.jl")
2739
include("pi.jl")
10+
include("wave.jl")
11+
include("i2c.jl")
12+
include("spiSerial.jl")
27413

275-
276-
end # module PiGPIO
14+
end

src/constants.jl

-1
Original file line numberDiff line numberDiff line change
@@ -440,5 +440,4 @@ _errors=[
440440
[_PI_BAD_ISR_INIT , "bad ISR initialisation"],
441441
[PI_BAD_FOREVER , "loop forever must be last chain command"],
442442
[PI_BAD_FILTER , "bad filter parameter"],
443-
444443
]

0 commit comments

Comments
 (0)