monoprice

package module
v0.0.0-...-ea909ba Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2019 License: LGPL-2.1 Imports: 7 Imported by: 1

README

monoprice-amp-go

This library wraps the Monoprice amplifier serial protocol, defined here. A small tool to set the power and volume of a specified zone can be found in the cmd directory.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidCommandCode is returned if an invalid command code is detected
	ErrInvalidCommandCode = errors.New("invalid command code")
	// ErrInvalidInput is detected if the command string format doesn't match as expected
	ErrInvalidInput = errors.New("invalid command string")
)
View Source
var (
	// ErrUnsupportedRange is returned if the requested parameter exceeds the supported range of inputs.
	ErrUnsupportedRange = errors.New("unsupported range")
)

Functions

This section is empty.

Types

type SerialAmplifier

type SerialAmplifier struct {
	// contains filtered or unexported fields
}

SerialAmplifier is an implementation of the Monoprice amplifier backed by a serial port.

func NewSerialAmplifier

func NewSerialAmplifier(port *serial.Port) (*SerialAmplifier, error)

NewSerialAmplifier creates a new serial amplifier using the supplied serial port. If the amplifier cannot be queried (i.e. if the port is not ready) an error will be returned.

func (*SerialAmplifier) ID

func (a *SerialAmplifier) ID() int

ID returns the ID (1-3) of this amplifier.

func (*SerialAmplifier) Reset

func (a *SerialAmplifier) Reset() error

Reset is used to clear the underlying serial port and reset things to a good state. This may be used if errors are detected on the port to clear any oddities being read. Any existing zone references will be invalidated and should not be used anymore.

func (*SerialAmplifier) Zone

func (a *SerialAmplifier) Zone(id int) *Zone

Zone retrieves the cached state of the specified zone. If the underlying zone may have changed (using a wall controller, for example), then refresh should be called on the returned zone before using the data.

type State

type State struct {
	IsOn              bool
	IsMuteOn          bool
	IsDoNotDisturbOn  bool
	IsPAOn            bool
	Volume            int
	Treble            int
	Bass              int
	Balance           int
	SourceChannelID   int
	IsKeypadConnected bool
}

State contains the current state of a given zone, as retrieved from the controller.

type Zone

type Zone struct {
	// contains filtered or unexported fields
}

Zone represents a single output on a receiver.

func (*Zone) ID

func (z *Zone) ID() string

ID returns the control ID of this zone.

func (*Zone) Refresh

func (z *Zone) Refresh() error

Refresh queries the amplifier for the current state of each field.

func (*Zone) SetBalance

func (z *Zone) SetBalance(level int) error

SetBalance applies the supplied balance level to the zone.

func (*Zone) SetBass

func (z *Zone) SetBass(level int) error

SetBass applies the supplied bass level to the zone.

func (*Zone) SetMute

func (z *Zone) SetMute(on bool) error

SetMute applies the supplied isMuteOn state to the zone.

func (*Zone) SetPower

func (z *Zone) SetPower(on bool) error

SetPower applies the supplied isOn state to the zone.

func (*Zone) SetSourceChannel

func (z *Zone) SetSourceChannel(channelID int) error

SetSourceChannel changes the source input used by the zone.

func (*Zone) SetTreble

func (z *Zone) SetTreble(level int) error

SetTreble applies the supplied treble level to the zone.

func (*Zone) SetVolume

func (z *Zone) SetVolume(level int) error

SetVolume applies the supplied volume level to the zone.

func (*Zone) State

func (z *Zone) State() *State

State returns a cached state of this zone. This will be in sync if all changes are made via this amp instance, however changes made by the wall controllers will not be reflected here.

Directories

Path Synopsis
cmd
ampcli command

Jump to

Keyboard shortcuts

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