scale

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: Apache-2.0 Imports: 4 Imported by: 6

Documentation

Index

Constants

View Source
const (

	// UnitUnknown denotes an unknown / invalid unit
	UnitUnknown = "--"

	// UnitGrams denotes metric units
	UnitGrams = "g"

	// UnitOz denotes imperial units
	UnitOz = "oz"
)

Variables

This section is empty.

Functions

func NewDefaultLogger added in v1.0.2

func NewDefaultLogger(debug bool) *zap.SugaredLogger

NewDefaultLogger instantiates a new default logger

Types

type Basic

type Basic interface {

	// ConnectionStatus returns the current connection status of the scale device
	ConnectionStatus() ConnectionStatus

	// BatteryLevel returns the current battery level
	BatteryLevel() float64

	// BatteryLevelRaw returns the current battery level in its raw form
	BatteryLevelRaw() int

	// Unit returns the current weight unit
	Unit() Unit

	// SetUnit sets the weight unit
	SetUnit(unit Unit) error

	// Tare tares the scale
	Tare() error

	// TogglePrecision toggles the weight precision between 0.1 and 0.01
	TogglePrecision() error

	// SetStateChangeHandler defines a handler function that is called upon state change
	SetStateChangeHandler(fn func(status ConnectionStatus))

	// SetStateChangeChannel defines a handler function that is called upon state change
	SetStateChangeChannel(ch chan ConnectionStatus)

	// SetDataHandler defines a handler function that is called upon retrieval of data
	SetDataHandler(fn func(data DataPoint))

	// SetDataChannel defines a handler function that is called upon retrieval of data
	SetDataChannel(ch chan DataPoint)

	// Close terminates the connection to the device
	Close() error
}

Basic denotes a basic coffee scale

type Buzzer

type Buzzer interface {

	// IsBuzzingOnTouch returs if the buzzer  (on user interaction) is on / off
	IsBuzzingOnTouch() bool

	// ToggleBuzzingOnTouch turns the buzzer (on user interaction) on / off
	ToggleBuzzingOnTouch() error

	// Buzz requests the scale to beep / buzz n times
	Buzz(n int) error
}

Buzzer denotes audible signaling functionality

type ConnectionStatus

type ConnectionStatus struct {
	Error error
	State
}

ConnectionStatus denotes the current status of the bluetooth device

type DataPoint

type DataPoint struct {
	TimeStamp time.Time
	Unit      Unit
	Weight    float64
}

DataPoint denotes a weight measurement at a certain point in time

func (DataPoint) Value

func (d DataPoint) Value() float64

Value provides a method to retrieve the current value (for interface use)

type DataPoints

type DataPoints []DataPoint

DataPoints denotes a set of data points (usually part of a brew process)

type Logger added in v1.0.2

type Logger interface {
	Error(args ...interface{})
	Errorf(format string, args ...interface{})

	Warn(args ...interface{})
	Warnf(format string, args ...interface{})

	Info(args ...interface{})
	Infof(format string, args ...interface{})

	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
}

Logger denotes a generic log interface that logging service must provide

type NullLogger added in v1.0.2

type NullLogger struct{}

NullLogger denotes a null-op logger that ignores all messages

func (*NullLogger) Debug added in v1.0.2

func (l *NullLogger) Debug(args ...interface{})

func (*NullLogger) Debugf added in v1.0.2

func (l *NullLogger) Debugf(format string, args ...interface{})

func (*NullLogger) Error added in v1.0.2

func (l *NullLogger) Error(args ...interface{})

func (*NullLogger) Errorf added in v1.0.2

func (l *NullLogger) Errorf(format string, args ...interface{})

func (*NullLogger) Info added in v1.0.2

func (l *NullLogger) Info(args ...interface{})

func (*NullLogger) Infof added in v1.0.2

func (l *NullLogger) Infof(format string, args ...interface{})

func (*NullLogger) Warn added in v1.0.2

func (l *NullLogger) Warn(args ...interface{})

func (*NullLogger) Warnf added in v1.0.2

func (l *NullLogger) Warnf(format string, args ...interface{})

type Scale

type Scale interface {
	Basic
	Buzzer
	Timer
}

Scale denotes the "default" scale containing all functionality

type State

type State int

State denotes a connection state

const (

	// StateScanning is active while scanning for a bluetooth device
	StateScanning State = iota

	// StateConnected is active while being connected to the scale
	StateConnected

	// StateDisconnected is active after being disconnected from the scale
	StateDisconnected
)

type Timer

type Timer interface {

	// StartTimer starts the timer / stopwatch
	StartTimer() error

	// StopTimer stops the timer / stopwatch
	StopTimer() error

	// ResetTimer resets the timer / stopwatch
	ResetTimer() error

	// ElapsedTime returns the current timer value
	ElapsedTime() time.Duration
}

Timer denotes timer / stopwatch functionality

type Unit

type Unit string

Unit denotes the unit of the weight measurement

type WithBuzzer

type WithBuzzer interface {
	Basic
	Buzzer
}

WithBuzzer denotes a scale with buzzer functionality

type WithTimer

type WithTimer interface {
	Basic
	Timer
}

WithTimer denotes a scale with timer functionality

Jump to

Keyboard shortcuts

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