gopitools

package
v0.0.0-...-eb28b5e Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2019 License: MIT Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLocalIPAddresses

func GetLocalIPAddresses() ([]string, error)

GetLocalIPAddresses gets a list of valid IPv4 addresses for the local machine

func GetPotentialAddresses

func GetPotentialAddresses(ip string) ([]string, error)

GetPotentialAddresses gets a list of IP addresses in the same subnet as the specified IP address that could, potentially, host a server. Note that this only supports Class 3 subnets for now.

func ReadAllText

func ReadAllText(path string) (string, error)

ReadAllText reads the text from the specified file path

Types

type CharDisplay

type CharDisplay struct {
	ClearOnClose bool
}

func (*CharDisplay) Clear

func (d *CharDisplay) Clear() error

Clear clears the LCD display.

func (*CharDisplay) Close

func (d *CharDisplay) Close()

Close releases and unmaps GPIO memory.

func (*CharDisplay) Init

func (d *CharDisplay) Init() error

Init initializes the Pin ready for use.

func (*CharDisplay) Message

func (d *CharDisplay) Message(text string) error

Message writes the text to the display. A NewLine character '\n' in the text moves the rest of the text tn the next line.

type Led

type Led struct {
	// Public values
	GpioLed        int
	TurnOffOnClose bool
	// contains filtered or unexported fields
}

Led allows you to control a GPIO connected LED

func (*Led) Close

func (l *Led) Close()

Close releases and unmaps GPIO memory.

func (*Led) Init

func (l *Led) Init() error

Init initializes the LED ready for use.

func (*Led) Off

func (l *Led) Off() error

Off turns the LED off

func (*Led) On

func (l *Led) On() error

On turns the LED on

func (*Led) Toggle

func (l *Led) Toggle() error

Toggle turns the LED on, if it's off, or off, if it's on.

type Mcp3008

type Mcp3008 struct {
}

Mcp3008 provides an interface to a MCP3008 chip, an 8 channel 10-bit ADC chip. This is currently a wrapper for a python routine until a pure golang solution can be found that provides similar functionality.

func (*Mcp3008) Close

func (m *Mcp3008) Close()

Close releases any resources.

func (*Mcp3008) Init

func (m *Mcp3008) Init() error

Init initializes the device ready for use.

func (*Mcp3008) Read

func (m *Mcp3008) Read(c ...int) ([]float64, error)

Read reads the current values from the ADC and returns them as a float slice containing 8 values. Each value ranges from 0 to 1.

type OneWireDevice

type OneWireDevice struct {
	ID       string
	Code     string
	Name     string
	SerialNo string
}

OneWireDevice holds the details about a connected device.

func GetDeviceList

func GetDeviceList() ([]OneWireDevice, error)

GetDeviceList returns a list of attached devices. The first characters before the dash are the family code. The characters after the dash are the unique serial number. Family codes are documented here: https://github.com/owfs/owfs-doc/wiki/1Wire-Device-List

type OneWireTemp

type OneWireTemp struct {
	// Public values
	ID string
	// contains filtered or unexported fields
}

OneWireTemp allows you to read the temperature from a One-Wire temperature device like a DS188B20 temperature probe.

func (*OneWireTemp) Close

func (t *OneWireTemp) Close()

Close releases any resources.

func (*OneWireTemp) Init

func (t *OneWireTemp) Init() error

Init initializes the device ready for use.

func (*OneWireTemp) IsInDevices

func (t *OneWireTemp) IsInDevices(l []OneWireDevice) bool

IsInDevices returns whether the list of devices contains the specified ID

func (*OneWireTemp) ReadTemp

func (t *OneWireTemp) ReadTemp() (float64, error)

ReadTemp returns the current temperature in celcius.

func (*OneWireTemp) ReadTempInFahrenheit

func (t *OneWireTemp) ReadTempInFahrenheit() (float64, error)

ReadTempInFahrenheit returns the current temperature in fahrenheit.

type PiModule

type PiModule interface {
	Close()
	Init() error
}

PiModule defines the interface for a component module.

type PiStatus

type PiStatus struct {
	HostName     string   // Current Host Name
	IPAddress    []string // Current IP Address
	OSName       string   // Operating System Name
	OSVersion    string   // Operating System version
	HWType       string   // Hardware type
	HWSerialNo   string   // Hardware SerialNo
	MachineID    string   // Machine ID
	CPUTemp      float64  // CPU temperature in Celcius
	GPUTemp      float64  // GPU temperature in Celcius
	IsThrottled  bool     // Is currently throttled
	FreeDisk     int      // Free Disk Space in bytes
	FreeDiskPerc int      // Free Disk Space in percentage
	AvailMem     int      // Available Memory in bytes
	Uptime       int      // CPU uptime in seconds

}

PiStatus holds current information about the Device

func (*PiStatus) Read

func (s *PiStatus) Read()

Read loads the status values into the struct

type Pin

type Pin struct {
	// Public values
	GpioNo         int
	TurnOffOnClose bool
}

Pin allows you to control a GPIO Pin

func (*Pin) Close

func (l *Pin) Close()

Close releases and unmaps GPIO memory.

func (*Pin) Init

func (l *Pin) Init() error

Init initializes the Pin ready for use.

func (*Pin) Off

func (l *Pin) Off() error

Off turns the Pin off

func (*Pin) On

func (l *Pin) On() error

On turns the Pin on

Jump to

Keyboard shortcuts

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