conf

package
v1.4.1-0...-1820da6 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ModLR000 = Module{ModLR, Rot000}
	ModLR090 = Module{ModLR, Rot090}
	ModLR180 = Module{ModLR, Rot180}
	ModLR270 = Module{ModLR, Rot270}
	ModRL000 = Module{ModRL, Rot000}
	ModRL090 = Module{ModRL, Rot090}
	ModRL180 = Module{ModRL, Rot180}
	ModRL270 = Module{ModRL, Rot270}
)

Because they are used quite frequently and there are 8 of them in total, I decided to create constants for each of them.

View Source
var (
	MarginLeft   = 30.0 * scaleFactor
	MarginRight  = 5.0 * scaleFactor
	MarginTop    = 30.0 * scaleFactor
	MarginBottom = 5.0 * scaleFactor

	AxesTextFont   = fonts.GoRegular
	AxesTextSize   = 12.0 * scaleFactor
	AxesTextColor  = color.Black
	AxesTickSep    = 5.0 * scaleFactor
	AxesTickHeight = 20.0 * scaleFactor
	AxesTickWidth  = 1.0 * scaleFactor
	AxesTickColor  = color.Black

	ModuleSize        = 400.0 * scaleFactor
	ModuleBorderWidth = 2.0 * scaleFactor
	ModuleBorderColor = color.Black
	ModuleFillColor   = color.AntiqueWhite
	ModuleTextFont    = fonts.GoBold
	ModuleTextSize    = 220.0 * scaleFactor
	ModuleTextColor   = color.DarkSlateGray

	LedFieldSize      = ModuleSize / float64(ModuleDim.X)
	LedSize           = LedFieldSize - 2.0
	LedBorderWidth    = 1.0 * scaleFactor
	LedBorderColor    = color.Black
	LedFillColor      = color.White.Alpha(0.7)
	LedStartFillColor = color.DarkGreen.Alpha(0.8)
	LedEndFillColor   = color.FireBrick.Alpha(0.8)
	LedTextFont       = fonts.GoRegular
	LedTextSize       = 16.0 * scaleFactor
	LedTextColor      = color.Black
	LedTextColorInv   = color.White

	// Trace is...
	TraceWidth     = 15.0 * scaleFactor
	TraceColor     = color.DarkSlateGray
	TraceBezierPos = 0.8
)

For the graphical output of the wiring diagram, many constants are used to configure the visual appearance.

View Source
var (
	ModuleDim = image.Point{10, 10}
)

This denotes the number of LEDs on a single module.

Functions

This section is empty.

Types

type CoordMap

type CoordMap []image.Point

Mit dem Typ CoordMap koennen Indizes der Lichterkette auf Koordinaten auf dem LEDGrid gemapped werden.

type IndexMap

type IndexMap [][]int

Mit diesem Typ koennen die Koordinaten der Pixel auf dem LEDGrid auf Indizes innerhalb der Lichterkette gemappt werden.

type Module

type Module struct {
	Type ModuleType
	Rot  RotationType
}

With values of type Module, you describe a certain module type, rotated by a specific angle.

func (Module) Coord

func (m Module) Coord(idx int) image.Point

func (Module) Draw

func (mod Module) Draw(gc *gg.Context, idxMod int)

This method draws a single module. The calling method/function must ensure, using translation and possibly rotation, that the origin of the coordinate system is positioned at the center of the module.

func (Module) DrawBorder

func (mod Module) DrawBorder(gc *gg.Context)

func (Module) DrawTrace

func (mod Module) DrawTrace(gc *gg.Context)

func (Module) Index

func (m Module) Index(pt image.Point) int

func (Module) MarshalText

func (m Module) MarshalText() ([]byte, error)

func (*Module) Scan

func (m *Module) Scan(state fmt.ScanState, verb rune) error

Module implementiert das Scanner-Interface, ist also in der Lage, via Funktion aus der Scanf-Familie eine konkrete Modul-Spezifikation zu lesen.

func (Module) String

func (m Module) String() string

Die textuelle Darstellung eines Moduls ist in der Einleitung am Anfang des Packages zu sehen: Modul-Typ und Rotationsart werden mit Doppelpunkt getrennt als zusammenhaengende Zeichenkette dargestell.

func (*Module) UnmarshalText

func (m *Module) UnmarshalText(text []byte) error

type ModuleConfig

type ModuleConfig []ModulePosition

Der Typ ModuleConfig schliesslich dient dazu, eine komplette Modul-Konfiguration zu speichern. Die Reihenfolge der Module ist relevant und entspricht der Verkabelung (d.h. die Einspeisung beginnt beim Modul an Position [0], geht dann zum Modul an Position [1] weiter, etc.)

func DefaultModuleConfig

func DefaultModuleConfig(size image.Point) ModuleConfig

func Load

func Load(fileName string) ModuleConfig

func (*ModuleConfig) AddModule

func (conf *ModuleConfig) AddModule(col, row int, mod Module)

Helps to build up a module configuration. Important: the Add's must be done along the LED chain. The configuration will be verified after each add.

func (ModuleConfig) Contains

func (conf ModuleConfig) Contains(pt image.Point) bool

Returns true if position pt is really visible on this LEDGrid.

func (ModuleConfig) Coord

func (conf ModuleConfig) Coord(idx int) image.Point

Returns the coordinates of the LED with index idx.

func (ModuleConfig) CoordMap

func (conf ModuleConfig) CoordMap() CoordMap

Mit dieser Methode kann der entsprechende CoordMap erstellt werden.

func (ModuleConfig) Draw

func (conf ModuleConfig) Draw(gc *gg.Context)

Draw is the workhorse of Plot. With Draw, you can create the configuration image into the graphical context, provided by the parameter gc.

func (ModuleConfig) DrawAxes

func (conf ModuleConfig) DrawAxes(gc *gg.Context)

func (ModuleConfig) Index

func (conf ModuleConfig) Index(pt image.Point) int

Returns the index of the position pt within the LED chain or -1 if this position is not on a module.

func (ModuleConfig) IndexMap

func (conf ModuleConfig) IndexMap() IndexMap

Erstellt ein Feld (Slice of Slices) fuer die direkte Uebersetzung von Pixel-Koordinaten zum Index innerhalb der Lichterkette. Das Feld ist Spalten-orientiert, damit ist die Verwendung der Koordinaten vergleichbar mit anderen Graphik-Funktionen.

func (ModuleConfig) Plot

func (conf ModuleConfig) Plot(fileName string)

With Plot, you can create a PNG file, showing the exact module config, the cabeling and the mapping between pixel coordinates and index on the LED chain.

func (ModuleConfig) Save

func (conf ModuleConfig) Save(fileName string)

Speichert die Konfiguration in conf in der Datei fileName ab.

func (ModuleConfig) Size

func (conf ModuleConfig) Size() image.Point

Returns the size of the LEDGrid as number of pixels.

func (ModuleConfig) Verify

func (conf ModuleConfig) Verify() error

func (ModuleConfig) VerifyModule

func (conf ModuleConfig) VerifyModule(i int) error

type ModulePosition

type ModulePosition struct {
	Col int    `json:"Col"`
	Row int    `json:"Row"`
	Mod Module `json:"Mod"`
	Idx int    `json:"-"`
}

Mit diesem Typ wird festgehalten, welches Modul (Typ und Ausrichtung) sich an welcher Stelle (Col, Row) innerhalb des gesamten Panels befindet und welches LED (Index innerhalb der gesamten Kette) am Anfang des Moduls steht.

func (ModulePosition) Bounds

func (m ModulePosition) Bounds() image.Rectangle

func (ModulePosition) Coord

func (m ModulePosition) Coord(idx int) image.Point

func (ModulePosition) Index

func (m ModulePosition) Index(pt image.Point) int

type ModuleType

type ModuleType int

There are two module types (with respect to the cabeling).

const (
	// Modules of this type start the cabeling at the top left corner and
	// end at the top right corner, therefore the cabeling runs from left to
	// right.
	ModLR ModuleType = iota
	// This module type start the cabeling at the top right corner and end at
	// the top left corner (running the cable from right to left).
	ModRL
)

func (ModuleType) Coord

func (m ModuleType) Coord(idx int) image.Point

func (ModuleType) Index

func (m ModuleType) Index(pt image.Point) int

func (*ModuleType) Set

func (m *ModuleType) Set(v string) error

Die Set-Methode ist eigentlich etwas aus dem Setter-Interface des Packages 'flag', wird hier aber verwendet um bestimmte Konfigurationen einfacher verarbeiten zu koennen.

func (ModuleType) String

func (m ModuleType) String() (s string)

type RotationType

type RotationType int

Each module can be rotated in steps of 90 degrees with respect to the base position (cable start/end point a the top row).

const (
	Rot000 RotationType = 0
	Rot090 RotationType = 90
	Rot180 RotationType = 180
	Rot270 RotationType = 270
)

func (*RotationType) Set

func (r *RotationType) Set(v string) error

func (RotationType) String

func (r RotationType) String() (s string)

Jump to

Keyboard shortcuts

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