Categorygithub.com/reef-pi/hal
modulepackage
0.0.0-20241230081938-0bb4bbd0e03a
Repository: https://github.com/reef-pi/hal.git
Documentation: pkg.go.dev

# README

reef-pi - Hardware Abstraction Layer

Build Status Go Report Card License GoDoc

Introduction

The hal package provide common types for hardware capabilities in reef-pi. It hides device specific details from the controller logic. reef-pi modules like ATO, and pH, uses hal interfaces to perform hardware based operations. The HAL interfaces cover metdata and methods for digital or analog I/O. Check out reef-pi/drivers for examples.

'hal' is mostly made of interfaces and void of business logic and or dependency package. A No-Op or null driver is included to ease testing.

Usage

import(
  "github.com/reef-pi/hal"
)

func main() {
  var d hal.Driver = hal.NewNoopDriver()
  d.Metadata()
  defer d.Close()

  input, _ := d.(hal.InputDriver)
  pin, _ := input.InputPin("GP4")
  v, _ := pin.Read()
  for _, pin := range input.InputPins() {
    fmt.Println(pin.Name())
  }

  output, _ := d.(hal.OutputDriver)
  pin, _ := output.OutputPin("GP4")
  pin.Write(false)

  var pwm PWMDriver = hal.NewNoopDrive()
  ch, _ := pwm.PWMChannel("foo")
  ch.Set(10.23)
  for _, ch := range pwm.PWMChannels() {
     fmt.Println(ch.Name())
  }
}


# Functions

No description provided by the author
ConvertToInt converts an interface to int if possible.
No description provided by the author
NoopFactory provides the factory to get NoopDriver parameters and NoopDrivers.
ToErrorString converts a map of failures to a single string.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

ConfigParameter represent a configuration parameter required by a driver.
No description provided by the author
Metadata represents basic information about a driver for the API response.

# Interfaces

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
InputPin represents an input pin with a single digital input value.
No description provided by the author
No description provided by the author
No description provided by the author
DriverFactory is responsible for creating drivers and providing information about a driver.
Pin represents a single-bit digital input or output.
No description provided by the author
No description provided by the author

# Type aliases

Capability represents the capabilities of a driver.
ConfigParameterType indicates the type of a configuration parameter.