Files
beatglow/config/config.go
T
2026-10-29 17:29:41 +01:00

100 lines
2.3 KiB
Go

// Package config contains the configuration structure and parser.
package config
// Config structure.
type Config struct {
Display Display `hcl:"display,block"`
Input Input `hcl:"input,block"`
Audio Audio `hcl:"audio,block"`
Player Player `hcl:"player,block"`
}
// Display configuration for OLED and TFT screens.
type Display struct {
FPS int `hcl:"fps,optional"`
Left DisplayConfig `hcl:"left,block"`
Right DisplayConfig `hcl:"right,block"`
Color DisplayConfig `hcl:"color,block"`
}
// DisplayConfig is the configuration for one display.
type DisplayConfig struct {
Name string
// Type of display.
Type string `hcl:"type"`
// Mode of operation; i2c or spi (defaults to i2c).
Mode string `hcl:"mode,optional"`
// Size of the display in pixels.
Size string `hcl:"size"`
// Bus is the I²C or SPI bus name.
Bus string `hcl:"bus,optional"`
// Address is the I²C address.
Address string `hcl:"addr,optional"`
// Frequency is the I²C or SPI bus frequency.
Freq string `hcl:"frequency,optional"`
// Reset is the reset pin.
Reset string `hcl:"reset,optional"`
// DC is the data/command pin.
DC string `hcl:"dc,optional"`
// CS is the chip select pin.
CS string `hcl:"cs,optional"`
// BL is the backlight pin.
BL string `hcl:"bl,optional"`
// Host name.
Host string `hcl:"host,optional"`
// Port name or number.
Port string `hcl:"port,optional"`
// Rotate the screen.
Rotate string `hcl:"rotate,optional"`
// Flip the screen vertically (if supported by hardware).
Flip bool `hcl:"flip,optional"`
// Mirror the screen horizontally (if supported by hardware).
Mirror bool `hcl:"flip,optional"`
}
// Input peripherals.
type Input struct {
Encoder Encoder `hcl:"encoder,block"`
}
// Encoder is a rotary encoder.
type Encoder struct {
Type string `hcl:"type"`
CW string `hcl:"cw,optional"`
CCW string `hcl:"ccw,optional"`
Switch string `hcl:"sw,optional"`
}
// Audio source provides PCM samples.
type Audio struct {
Type string `hcl:"type"`
Path string `hcl:"path,optional"`
Host string `hcl:"host,optional"`
Rate float64 `hcl:"rate,optional"`
Channels int `hcl:"channels,optional"`
Bits int `hcl:"bits,optional"`
}
// Player controls the audio.
type Player struct {
Type string `hcl:"type"`
Host string `hcl:"host,optional"`
Password string `hcl:"password,optional"`
}