stream

package
v0.0.0-...-b27a102 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SaturationMinChill = 0.2
	SaturationMaxChill = 0.6
	SaturationMinFun   = 0.5
	SaturationMaxFun   = 1.0
	SaturationMinWide  = 0.0
	SaturationMaxWide  = 1.0
)

Variables

View Source
var SaturationMax = SaturationMaxChill
View Source
var SaturationMin = SaturationMinChill

Functions

This section is empty.

Types

type AckMessage

type AckMessage struct {
	CalibrationMessage
	AckID uint8 `json:"ackID"`
}

AckMessage indicates that a frame has been displayed

type AggregatedData

type AggregatedData struct {
	Bins []*Bin `json:"bins"`
}

type Animation

type Animation interface {
	CalculateFrame(runtimeMs int64) *Frame
}

An Animation implements a way to render a specific animation.

type Bin

type Bin struct {
	Location Point   `json:"loc"`
	Hits     int32   `json:"hits"`
	Pixels   []int32 `json:"pixels"`
}

type Calibrate

type Calibrate struct {
	C chan bool
	// contains filtered or unexported fields
}

Calibrate finds the locations of LEDs in polar co-ordinates where the radius is the distance projected onto the cone-shaped tree from top to bottom

func NewCalibrate

func NewCalibrate(config Config, client mqtt.Client) *Calibrate

NewCalibrate creates an instance of a Calibrate struct

func (*Calibrate) CalculateFrame

func (c *Calibrate) CalculateFrame(runtimeMs int64) *Frame

CalculateFrame gets the onscreen frame

func (*Calibrate) Subscribe

func (c *Calibrate) Subscribe()

Subscribe to listen to the mobile app

type CalibrationMessage

type CalibrationMessage struct {
	Type string `json:"type"`
}

CalibrationMessage base that indicates message type

type Config

type Config struct {
	Mqtt struct {
		URL      string `yaml:"url"`
		Username string `yaml:"username"`
		Password string `yaml:"password"`
		Topics   struct {
			Stream          string `yaml:"stream"`
			Ack             string `yaml:"ack"`
			CalibrateClient string `yaml:"calibrateClient"`
			CalibrateServer string `yaml:"calibrateServer"`
		}
	} `yaml:"mqtt"`
}

Config for the application

type Controller

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

Controller that manages animations.

func NewController

func NewController(runtimeMs int64, frameRate float64, animationTime time.Duration,
	calibrate *Calibrate) *Controller

NewController creates an instance of a Controller.

func (*Controller) CalculateFrame

func (c *Controller) CalculateFrame(runtimeMs int64) *Frame

CalculateFrame calculates a frame using the current and next animation

func (*Controller) Run

func (c *Controller) Run()

Run causes the Controller to cycle through animations.

func (*Controller) SprintColour

func (c *Controller) SprintColour(colour colorful.Color) string

func (*Controller) SprintColours

func (c *Controller) SprintColours(colours []colorful.Color) string

type DataMessage

type DataMessage struct {
	CalibrationMessage
	Locations [][]float64 `json:"locations"`
}

DataMessage conveying the locations of LEDs from the mobile app

type Frame

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

Frame represents a frame of RGB pixels to display on an ledrx device.

func NewFrame

func NewFrame() *Frame

NewFrame creates a new Frame instance.

func (*Frame) InterpolateFrame

func (f *Frame) InterpolateFrame(f2 *Frame, transitionPoint float64) *Frame

InterpolateFrame merges two frames.

func (*Frame) MarshalBinary

func (f *Frame) MarshalBinary() (data []byte, err error)

MarshalBinary converts a Frame into binary data.

type GradientTable

type GradientTable []struct {
	Hue        float64
	Saturation float64
	Pos        float64
}

GradientTable stores a look-up table of colours interpolated by hue.

func (GradientTable) GetColor

func (g GradientTable) GetColor(t float64, l float64) colorful.Color

GetColor gets a colour at the specified point on the look-up table.

func (GradientTable) GetColorFixedSaturation

func (g GradientTable) GetColorFixedSaturation(t float64, s float64, l float64) colorful.Color

GetColorFixedSaturation gets a colour at the specified point on the look-up table.

type GradientTrail

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

A GradientTrail is an Animation that cycles a gradient along an led strip.

func NewGradientTrail

func NewGradientTrail(gradient GradientTable, trailLength uint32,
	luminance float64, startTimeMs int64, pixelsPerMs float64) *GradientTrail

NewGradientTrail creates an instance of a GradientTrail object.

func (*GradientTrail) CalculateFrame

func (g *GradientTrail) CalculateFrame(runtimeMs int64) *Frame

CalculateFrame creates a new Frame instance.

type InfinityStripe

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

A GradientTrail is an Animation that cycles a gradient along an led strip.

func NewInfinityStripe

func NewInfinityStripe(startTimeMs int64, pixelsPerMs float64, stripeGenerator stripe.StripeGenerator) *InfinityStripe

NewInfinityStripe creates an instance of a InfinityStripe object.

func (*InfinityStripe) CalculateFrame

func (s *InfinityStripe) CalculateFrame(runtimeMs int64) *Frame

CalculateFrame creates a new Frame instance.

type MultiTwinkle

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

A MultiTwinkle is an Animation that twinkles random particles.

func NewMultiTwinkle

func NewMultiTwinkle(scintillationChance int32, backColours []colorful.Color, lut []float64, runtimeMs int64) *MultiTwinkle

NewMultiTwinkle creates an instance of a Twinkle object.

func (*MultiTwinkle) CalculateFrame

func (t *MultiTwinkle) CalculateFrame(runtimeMs int64) *Frame

CalculateFrame creates a new Frame instance.

type Pixel

type Pixel struct {
	Resolved bool  `json:"resolved"`
	Location Point `json:"loc"`
}

type Point

type Point struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

Point that represents LED location

type RawCalibrationData

type RawCalibrationData struct {
	Pixels    []int32 `json:"pixels"`
	Locations []Point `json:"locations"`
}

type Streak

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

A Streak is an Animation that creates streaks across the tree that fade in then out.

func NewStreak

func NewStreak(runtimeMs int64, streakChance int32, backColour colorful.Color) *Streak

NewStreak creates an instance of a Streak object.

func (*Streak) CalculateFrame

func (s *Streak) CalculateFrame(runtimeMs int64) *Frame

CalculateFrame creates a new Frame instance.

type Streamer

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

Streamer that streams RGB data frames to an ledrx device.

func NewStreamer

func NewStreamer(config Config, client mqtt.Client) *Streamer

NewStreamer creates an instance of a Streamer.

func (*Streamer) Run

func (s *Streamer) Run()

Run causes the Streamer to send Frames continuously.

func (*Streamer) SendFrame

func (s *Streamer) SendFrame()

SendFrame sends a frame as binary over MQTT to an ledrx device.

func (*Streamer) Subscribe

func (s *Streamer) Subscribe()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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