common

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrProfileNotFound = errors.New("light effect could not be found")
View Source
var ErrSpeakerContextReused = errors.New("the speaker was already initialized, the existing context is reused")

Functions

func AwaitSignal

func AwaitSignal() os.Signal

func ChangeIntensity

func ChangeIntensity(delta int)

func ChangeVolume

func ChangeVolume(delta int)

func ConfigChangeListener added in v1.1.0

func ConfigChangeListener(handler func())

func Configure

func Configure(cfg *Config)

func EventFire

func EventFire(ev Event)

func EventListen

func EventListen(listener func(Event))

func EventLoop

func EventLoop()

func GetIntensity

func GetIntensity() int

func GetSpeaker

func GetSpeaker(rate beep.SampleRate, buffersize int, volume int) (int, error)

func GetVolume

func GetVolume() int

func Play

func Play(streamers ...beep.Streamer)

func SetIntensity

func SetIntensity(intensity int)

func SetVolume

func SetVolume(volume int)

Types

type Config

type Config struct {
	Meta struct {
		Version string
		Build   string
		Name    string `env:"NAME" env-default:"Deichwave"`
	} `env-prefix:"META_"`
	File  string `env:"CONFIG" env-default:"config/default.toml"`
	Debug bool   `env:"DEBUG" env-default:"false"`
	Audio struct {
		Rate    int `toml:"rate" env:"RATE" env-default:"44100"`
		Buffer  int `toml:"buffer" env:"BUFFER" env-default:"5000"`
		Quality int `toml:"quality" env:"QUALITY" env-default:"6"`
		Volume  int `toml:"volume" env:"VOLUME" env-default:"10"`
	} `toml:"audio" env-prefix:"AUDIO_"`
	Sounds struct {
		Path       string `toml:"path" env:"DIR" env-default:"data/sounds/effects"`
		Ext        string `toml:"ext" env:"EXT" env-default:".ogg"`
		Randomizer string `toml:"randomizer" env:"RND" env-default:".random"`
		Volume     int    `toml:"volume" env:"VOLUME" env-default:"100"`
	} `toml:"sounds" env-prefix:"SOUNDS_"`
	Music struct {
		Path     string `toml:"path" env:"DIR" env-default:"data/music/playlists"`
		Ext      string `toml:"ext" env:"EXT" env-default:".ogg"`
		Volume   int    `toml:"volume" env:"VOLUME" env-default:"50"`
		StartRNG []int  `toml:"startrng" env:"STARTRNG" env-default:"95,5"`
		EndRNG   []int  `toml:"endrng" env:"ENDRNG" env-default:"30,70"`
	} `toml:"music" env-prefix:"MUSIC_"`
	Lights struct {
		Path string `toml:"path" env:"DIR" env-default:"data/lights/effects"`
		Ext  string `toml:"ext" env:"EXT" env-default:".tengo"`
	} `toml:"lights" env-prefix:"LIGHTS_"`
	Shell map[string][]string `toml:"shell"`
	Hooks map[string][]string `toml:"hooks"`
	REST  struct {
		Port int `toml:"port" env:"PORT" env-default:"3000"`
	} `toml:"rest" env-prefix:"REST_"`
	LEDs map[string]struct {
		Order int `toml:"order"`
		Count int `toml:"count"`
	} `toml:"leds"`
	GPIO map[string]struct {
		Chip     string   `toml:"chip"`
		Pins     []int    `toml:"pins"`
		Type     string   `toml:"type"`
		Debounce int      `toml:"debounce"`
		Actions  []string `toml:"actions"`
	} `toml:"gpio"`
	Hardware struct {
		LEDBrightness int `toml:"led-brightness" env:"LED_BRIGHTNESS" env-default:"100"`
		LEDPin        int `toml:"led-pin" env:"LED_PIN" env-default:"18"`
	} `toml:"hardware" env-prefix:"HW_"`
}

type Event

type Event struct {
	Origin string `json:"origin"`
	Name   string `json:"name"`
	Type   string `json:"type"`
}

type ProfileSwitcher added in v1.1.0

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

func NewProfilSwitcher added in v1.1.0

func NewProfilSwitcher(cfg *Config) (ProfileSwitcher, error)

func (*ProfileSwitcher) ListProfiles added in v1.1.0

func (p *ProfileSwitcher) ListProfiles() []string

func (*ProfileSwitcher) SetProfile added in v1.1.0

func (p *ProfileSwitcher) SetProfile(name string) error

Jump to

Keyboard shortcuts

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