cec

package module
v0.0.0-...-bd105f2 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2019 License: MIT Imports: 8 Imported by: 0

README

cec.go - a golang binding for libcec

cec.go is a Go interface to LibCEC.

Install

Make sure you have libcec and it's header files installed (apt-get install libcec-dev)

go get github.com/chbmuc/cec

Getting Started

A simple example to turn on the TV:

package main

import (
	"fmt"
	"github.com/chbmuc/cec"
)

func main() {
	c, err := cec.Open("", "cec.go")
	if err != nil {
		fmt.Println(err)
	}
	c.PowerOn(0)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetKeyCodeByName

func GetKeyCodeByName(name string) int

GetKeyCodeByName - get the keycode by its name

func GetLogicalAddressByName

func GetLogicalAddressByName(name string) int

GetLogicalAddressByName - get logical address by its name

func GetLogicalNameByAddress

func GetLogicalNameByAddress(addr int) string

GetLogicalNameByAddress - get logical name by address

func GetVendorByID

func GetVendorByID(id uint64) string

GetVendorByID - Get vendor by ID

Types

type Command

type Command struct {
	Operation string
	// contains filtered or unexported fields
}

type Connection

type Connection struct {
	Commands chan *Command
	// contains filtered or unexported fields
}

Connection class

func Open

func Open(name string, deviceName string) (*Connection, error)

Open - open a new connection to the CEC device with the given name

func (*Connection) Destroy

func (c *Connection) Destroy()

Destroy - destroy the cec connection

func (*Connection) GetActiveDevices

func (c *Connection) GetActiveDevices() [16]bool

GetActiveDevices - returns an array of active devices

func (*Connection) GetDeviceOSDName

func (c *Connection) GetDeviceOSDName(address int) string

GetDeviceOSDName - get the OSD name of the specified device

func (*Connection) GetDevicePhysicalAddress

func (c *Connection) GetDevicePhysicalAddress(address int) string

GetDevicePhysicalAddress - Get the physical address of the device at the given logical address

func (*Connection) GetDevicePowerStatus

func (c *Connection) GetDevicePowerStatus(address int) string

GetDevicePowerStatus - Get the power status of the device at the given address

func (*Connection) GetDeviceVendorID

func (c *Connection) GetDeviceVendorID(address int) uint64

GetDeviceVendorID - Get the Vendor-ID of the device at the given address

func (*Connection) IsActiveSource

func (c *Connection) IsActiveSource(address int) bool

IsActiveSource - check if the device at the given address is the active source

func (*Connection) Key

func (c *Connection) Key(address int, key interface{})

Key - send key press and release commands (hold key for 10ms) to the device at the given address, the key code can be specified as a hex-code or by its name

func (*Connection) KeyPress

func (c *Connection) KeyPress(address int, key int) error

KeyPress - send a key press (down) command code to the given address

func (*Connection) KeyRelease

func (c *Connection) KeyRelease(address int) error

KeyRelease - send a key releas command to the given address

func (*Connection) List

func (c *Connection) List() map[string]Device

List - list active devices (returns a map of Devices)

func (*Connection) Mute

func (c *Connection) Mute() error

Mute - send a mute/unmute command to the amp if present

func (*Connection) PowerOn

func (c *Connection) PowerOn(address int) error

PowerOn - power on the device with the given logical address

func (*Connection) SetHdmiPort

func (c *Connection) SetHdmiPort(address int, port int) error

SetHdmiPort - send an HDMI command code to the given address with the specified port

func (*Connection) Standby

func (c *Connection) Standby(address int) error

Standby - put the device with the given address in standby mode

func (*Connection) Transmit

func (c *Connection) Transmit(command string)

Transmit CEC command - command is encoded as a hex string with colons (e.g. "40:04")

func (*Connection) VolumeDown

func (c *Connection) VolumeDown() error

VolumeDown - send a volume down command to the amp if present

func (*Connection) VolumeUp

func (c *Connection) VolumeUp() error

VolumeUp - send a volume up command to the amp if present

type Device

type Device struct {
	OSDName         string
	Vendor          string
	LogicalAddress  int
	ActiveSource    bool
	PowerStatus     string
	PhysicalAddress string
}

Device structure

Jump to

Keyboard shortcuts

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