runner

package
v0.0.0-...-f515710 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2021 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package runner orchestrates the overall system behavior. This includes rendering scenes, handling button presses, and writing to the display.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buttons

type Buttons interface {
	RegisterHandlers(a, b, c, d, e func())
}

Buttons defines the behavior that the runner expects for the buttons.

type Display

type Display interface {
	SetBuffer([][]byte)
	SetBrightness(brightness byte)
	Show() error
	Width() int
	Height() int
}

Display defines the behavior that the runner expects for the display object.

type Pixel

type Pixel interface {
	SetColor(r, g, b byte)
	SetBrightness(brightness byte)
}

Pixel defines the behavior that the runner expects for the LED pixel.

type Runner

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

Runner orchestrates the overall system behavior.

func New

func New(
	config *scenes.Config,
	scenes map[scenes.Type]scenes.Scene,
	sceneTypes []scenes.Type,
	display Display, buttons Buttons,
	pixel Pixel,
	saveConfig func(),
	exit <-chan bool,
) *Runner

New returns a new Runner.

func (*Runner) Run

func (r *Runner) Run() error

Run is the main orchestration loop. It has several responsibilities.

First, it kicks off a goroutine to send color data to the LED pixel in a rainbow pattern. It keeps track of total and per-frame timings. It uses these to calculate FPS, as well as trigger the current scene to render. Finally, tt sends the resulting rendered buffer to the display, and pauses if needed to limit the maximum FPS.

Jump to

Keyboard shortcuts

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