Skip to content
Snippets Groups Projects
Select Git revision
  • b7076b2afbe1e62f3429228ec980843f18a63cba
  • main default protected
  • cont-frb/moberg-review
  • v0.9.26
  • v0.9.25
  • v0.9.24
  • v0.9.23
  • v0.9.22
  • v0.9.21
  • v0.9.20
  • v0.9.19
  • v0.9.18
  • v0.9.17
  • v0.9.16
  • v0.9.15
  • v0.9.14
  • v0.9.13
  • v0.9.12
  • v0.9.11
  • v0.9.10
  • v0.9.9
  • v0.9.8
  • v0.9.7
23 results

DigitalIn.jl

Blame
  • DigitalIn.jl 1.06 KiB
    mutable struct DigitalInChannel
        context::Ptr{Nothing}
        read::Ptr{Nothing}
    end
    
    mutable struct DigitalIn
        moberg::Moberg
        index::UInt32
        channel::DigitalInChannel
        function DigitalIn(moberg::Moberg, index::Unsigned)
            channel = DigitalInChannel(0,0)
            checkOK(ccall((:moberg_digital_in_open, "libmoberg"),
                           Status,
                           (Moberg, Cint, Ref{DigitalInChannel}),
                           moberg, index, channel));
            self = new(moberg, index, channel)
            finalizer(close, self)
            self
        end
    end
    
    function close(din::DigitalIn)
        DEBUG && println("closing $(din)")
        checkOK(ccall((:moberg_digital_in_close, "libmoberg"),
                      Status,
                      (Moberg, Cint, DigitalInChannel),
                      din.moberg, din.index, din.channel))
    end
    
    function read(din::DigitalIn)
        result = Ref{Cint}(0)
        checkOK(ccall(din.channel.read,
                      Status,
                      (Ptr{Nothing}, Ptr{Cint}),
                      din.channel.context, result))
        return result[] != 0
    end