mcp3008

package
v0.15.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2021 License: BSD-3-Clause Imports: 3 Imported by: 15

Documentation

Overview

Package mcp3008 implements a driver for the MCP3008 Analog to Digital Converter.

Datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/21295d.pdf

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ADCPin

type ADCPin struct {
	machine.Pin
	// contains filtered or unexported fields
}

ADCPin is the implementation of the ADConverter interface.

func (ADCPin) Configure

func (p ADCPin) Configure()

Configure here just for interface compatibility.

func (ADCPin) Get

func (p ADCPin) Get() uint16

Get the current reading for a specific ADCPin.

type Device

type Device struct {
	CH0 ADCPin
	CH1 ADCPin
	CH2 ADCPin
	CH3 ADCPin
	CH4 ADCPin
	CH5 ADCPin
	CH6 ADCPin
	CH7 ADCPin
	// contains filtered or unexported fields
}

Device wraps MCP3008 SPI ADC.

func New

func New(b drivers.SPI, csPin machine.Pin) *Device

New returns a new MCP3008 driver. Pass in a fully configured SPI bus.

func (*Device) Configure

func (d *Device) Configure()

Configure sets up the device for communication

func (*Device) GetADC

func (d *Device) GetADC(ch int) ADCPin

GetADC returns an ADC for a specific channel.

func (*Device) Read

func (d *Device) Read(ch int) (uint16, error)

Read analog data from channel

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL