Documentation ¶
Overview ¶
Package fdevents implements epoll_wait loop for GPIO events and exposes a channel interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct { RisingEdge bool // Whether this event is triggered by a rising edge. Time time.Time // The best estimate of time of event occurrence. }
Event is a GPIO event.
type FdEvents ¶
type FdEvents struct {
// contains filtered or unexported fields
}
FdEvents converts epoll_wait loops to a chanel.
func New ¶
func New(fd int, closeFdOnClose bool, fdEpollEvents uint32, readFd ReadFdFunc) (events *FdEvents, err error)
New creates a FdEvents and returns any error encountered. The returned FdEvents waits fd for fdEpollEvents in a epoll_wait loop. If epoll_wait returns successfully, readFd is called to generate a value, and that value is sent to the event channel returned by Events.
readFd should return the best estimate of time of event occurrence.
Package fdevents will not block sending to the channel: it only keeps the lastest value in the channel.
func (*FdEvents) Close ¶
Close stops the epoll_wait loop, close the fd, and close the event channel.
func (*FdEvents) Events ¶
Events returns a channel from which the occurrence time of events can be read. The best estimate of time of event occurrence is sent to the returned channel, and the channel is closed when events is closed.
Package fdevents will not block sending to the channel: it only keeps the lastest value in the channel.