litra

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

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

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 5 Imported by: 5

README

Go Logitech Litra Glow Driver
=============================

This GO module implements a basic way to interact with a Logitech Litra Glow
light. It uses `karalabe/usb <https://github.com/karalabe/usb>`_ for the low
level USB communications. I have only tested this on Linux.

The reverse engineered USB protocol comes from the `kharyam/litra-driver
<https://github.com/kharyam/litra-driver>`_ Python implementation.

UDEV Config
-----------

Before you can use the light on Linux as a non-root user, you need to set up
the following UDEV rule in ``/etc/udev/rules.d/82-litra-glow.rules``::

	SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c900", MODE:="0666", GROUP="plugdev"
	SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c900", TAG+="uaccess"
	KERNEL=="hidraw*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c900", TAG+="uaccess"

Then restart UDEV to refresh it rules as root::

	udevadm control --reload-rules && udevadm trigger

And then (re-)plugin your light again.

Usage
-----

Obtain the driver with::

	go get derickr/go-litra-driver

Import the driver in your ``.go`` file::

	import derickr/go-litra-driver

In order to use the driver to control the light, create a new instance of the
``LitraDevice`` struct::

	ld, err := litra.New()

Currently, the driver only supports one light. If the driver can't open the
USD device, an error will be returned.

You can then use the ``ld`` variable as a handle to issue control statements.

================  =============================  =====================================
Task              Method                         Arguments
----------------  -----------------------------  -------------------------------------
Turn Light On     ld.TurnOn()
Turn Light Off    ld.TurnOff()
Set Brightness    ld.SetBrightness(level int)    ``level`` is brightness from 0 to 100
Set Temperature   ld.SetTemperature(temp int16)  ``temp`` is light temperature
                                                 from 2700K to 6500K
Close Connection  ld.Close()
================  =============================  =====================================

If you supply an out-of-range value to ``SetBrightness`` or ``SetTemperature``
it clamps to the supported range.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LitraDevice

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

func New

func New() (*LitraDevice, error)

func (*LitraDevice) Close

func (d *LitraDevice) Close()

func (*LitraDevice) SetBrightness

func (d *LitraDevice) SetBrightness(level int)

func (*LitraDevice) SetTemperature

func (d *LitraDevice) SetTemperature(temp int16)

func (*LitraDevice) TurnOff

func (d *LitraDevice) TurnOff()

func (*LitraDevice) TurnOn

func (d *LitraDevice) TurnOn()

Jump to

Keyboard shortcuts

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