-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pingo.jl #1
Comments
These "parts" API will be on top of an intermediate level API (to define) board = Board()
led_pin = Pin(board, 13)
mode(led_pin, OUTPUT::MODE) # OUTPUT::MODE being an Enum
while true
hi(led_pin)
sleep(1)
lo(led_pin)
sleep(1)
end |
https://gist.github.com/scls19fr/0e95131dc3ec6cd061da11377445215d see also about pingo (Python IO for several board) and https://github.com/RPi-Distro/python-gpiozero/
|
(Auto)Conversion of parameters (for an easier approach) struct Pin # struct (v>=0.6)
number::Int
end
struct State # struct (v>=0.6)
val::Int
end
function set(pin::Pin, state::State)
println(pin)
end
function set(pin, state)
pin = convert(Pin, pin)
state = convert(State, state)
set(pin, state)
end
convert(::Type{Pin}, pin::Int) = Pin(pin)
convert(::Type{Pin}, pin::Pin) = pin
#function convert(::Type{State}, state::Int)
# if state in [0, 1]
# State(state)
# else
# error("state must be 0 or 1")
# end
#end
#
convert(::Type{State}, state::Int) = state in [0, 1] ? State(state) : error("state must be 0 or 1")
convert(::Type{State}, state::State) = state
pin = Pin(10)
state = State(0)
set(pin, state)
set(10, 0)
#set(10, 100) |
Pingo.jl
An input/output library based on https://github.com/aviks/PiGPIO.jl (for RaspberryPi)
but that could be use for other board also
inspired by https://github.com/pingo-io/pingo-py
and https://github.com/RPi-Distro/python-gpiozero/
A possible "parts" (just led) API usage might be
pin
might be an integer or aDigitalPin
board
shouldn't be necessary (if no board is given we should use aDefaultBoard
object)An example with led and button
an other (maybe harder to implement) might be
with
keywords: callback ; event driven programming ; signal slot ; publish subscribe ; pattern ; dispatch module ; observer pattern ; message ; messaging ; dispatching
The text was updated successfully, but these errors were encountered: