dmx

package module
v0.0.0-...-1ec6837 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2013 License: GPL-3.0 Imports: 4 Imported by: 12

README

DMX for Go

A simple Go package to send DMX messages.

Copyright (c) 2013 AKUALAB INC. All Rights Reserved. http://www.akualab.com - @akualab - info@akualab.com

Credits

Ported from pySimpleDMX by @c0z3n

DMX Hardware

To send DMX messages using a serial port over USB, you can use one of these adaptors:

You can buy an 86 RGB LED Light PAR DMX-512 on eBay for $30.

Install

go get github.com/akualab/dmx

Example

package main

import (
    "github.com/akualab/dmx"
)

func main() {

    dmx, e := dmx.NewDMXConnection("/dev/ttyUSB0")
    if e != nil {
        log.Fatal(e)
    }

    // Set values for channels.
    dmx.SetChannel(1, 100)
    dmx.SetChannel(2, 70)
    dmx.SetChannel(3, 130)
    dmx.SetChannel(4, 180)

    // Send!
    dmx.Render()
}

Run Random Color Example

go run example/random-color.go

License

GPL Version 3 - http://www.gnu.org/licenses/gpl.html

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Documentation

Overview

Simple Go package to send DMX messages. Copyright (c) 2013 AKUALAB INC. All Rights Reserved. www.akualab.com - @akualab - info@akualab.com

CREDITS: Ported from pySimpleDMX (https://github.com/c0z3n/pySimpleDMX) Written by Michael Dvorkin

GNU General Public License v3. http://www.gnu.org/licenses/

Index

Constants

View Source
const (
	START_VAL       = 0x7E
	END_VAL         = 0xE7
	BAUD            = 57600
	TIMEOUT         = 1
	DEV             = "/dev/ttyUSB0"
	FRAME_SIZE      = 511
	FRAME_SIZE_LOW  = byte(FRAME_SIZE & 0xFF)
	FRAME_SIZE_HIGH = byte(FRAME_SIZE >> 8 & 0xFF)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DMX

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

A serial DMX connection.

func NewDMXConnection

func NewDMXConnection(device string) (dmx *DMX, err error)

Creates a new DMX connection using a serial device.

func (*DMX) ChannelMap

func (dmx *DMX) ChannelMap(brightness, red, green, blue int)

Convenience method to map colors and brightness to channels.

func (*DMX) ClearAll

func (dmx *DMX) ClearAll()

Turn off all channels.

func (*DMX) ClearChannel

func (dmx *DMX) ClearChannel(channel int) error

Turn off a specific channel.

func (*DMX) Close

func (dmx *DMX) Close() error

Close serial port.

func (*DMX) Render

func (dmx *DMX) Render() error

Send frame to serial device.

func (*DMX) SendRGB

func (dmx *DMX) SendRGB(brightness, red, green, blue byte) (e error)

Configures RGB+Brightness channels and renders the color. Call ChannelMap to configure the RGB channels before calling this method.

func (*DMX) SetChannel

func (dmx *DMX) SetChannel(channel int, val byte) error

Set channel level in the dmx frame to be rendered the next time Render() is called.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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