hamdial

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 10 Imported by: 0

README

HamDial

HamDial is a Go library for using the Ulanzi D100H input device in Go applications on Linux. It uses the /dev/hidrawN node created by the Linux kernel to communicate with the device. For more details about the communication protocol see protocol.md.

Usage

The very least to do in order to use the dial:

dial, err := hamdial.OpenDial("Ulanzi Dial")
if err != nil {
	log.Fatal(err)
}
defer dial.Close()
dial.Notify(eventLogger{})
err = dial.Run()
if err != nil {
	log.Fatal(err)
}

For a more advanced example see root.go.

dialctl

The command line program dialctl can be used to test and debug the BLE communication between the library and the device. It is also a blueprint on how to use the library.

Prerequisites

To use the D100H with HamDial, the user must be in group plugdev and there must be a custom udev rule in place.

# /etc/dev/rules.d/70-ulanzi-dial.rules
KERNEL=="hidraw*", KERNELS=="0005:FFF1:0082.*", TAG+="uaccess"
# add the user to the plugdev group
sudo usermod -aG plugdev $USER

# reload the udev rules
sudo udevadm control --reload

After adding the user to the plugdev group you need to log out and log in again to make the assignment effective in your session.

After reloading the udev rule with udevadm control --reload you must disconnect and reconnect the D100H to make the rule effective.

License

This software is published under the MIT License.

Copyright Florian Thienel

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDisconnected = errors.New("hamdial: the dial was disconnected")

Functions

This section is empty.

Types

type Button

type Button int
const (
	NoButton Button = iota
	Button1
	Button2
	Button3
	Button4
	Button5
	Button6
	Button7
	DialButton
)

type ButtonPressedListener

type ButtonPressedListener interface {
	ButtonPressed(button Button)
}

type ButtonPressedListenerFunc

type ButtonPressedListenerFunc func(button Button)

func (ButtonPressedListenerFunc) ButtonPressed

func (f ButtonPressedListenerFunc) ButtonPressed(button Button)

type ButtonReleasedListener

type ButtonReleasedListener interface {
	ButtonReleased(button Button)
}

type ButtonReleasedListenerFunc

type ButtonReleasedListenerFunc func(button Button)

func (ButtonReleasedListenerFunc) ButtonReleased

func (f ButtonReleasedListenerFunc) ButtonReleased(button Button)

type Dial

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

func Open

func Open(info DialInfo) (*Dial, error)

func OpenDial

func OpenDial(localName string) (*Dial, error)

func OpenDialAt

func OpenDialAt(address string) (*Dial, error)

func (*Dial) Address

func (d *Dial) Address() string

func (*Dial) Close

func (d *Dial) Close() error

func (*Dial) Name

func (d *Dial) Name() string

func (*Dial) Notify

func (d *Dial) Notify(listener any)

func (*Dial) Path

func (d *Dial) Path() string

func (*Dial) Run

func (d *Dial) Run(ctx context.Context) error

func (*Dial) Send

func (d *Dial) Send(payload []byte) error

func (*Dial) SetHapticFeedback

func (d *Dial) SetHapticFeedback(enabled bool) error

type DialInfo

type DialInfo struct {
	Path    string
	Name    string
	Address string
}

func ListDials

func ListDials(localName string) ([]DialInfo, error)

type DialTurnedListener

type DialTurnedListener interface {
	DialTurned(direction Direction)
}

type DialTurnedListenerFunc

type DialTurnedListenerFunc func(direction Direction)

func (DialTurnedListenerFunc) DialTurned

func (f DialTurnedListenerFunc) DialTurned(direction Direction)

type Direction

type Direction int
const (
	Clockwise        Direction = 1
	CounterClockwise Direction = -1
)

type DisconnectedListener

type DisconnectedListener interface {
	Disconnected()
}

type DisconnectedListenerFunc

type DisconnectedListenerFunc func()

func (DisconnectedListenerFunc) Disconnected

func (f DisconnectedListenerFunc) Disconnected()

type ReportListener

type ReportListener interface {
	Report(reportID byte, data []byte)
}

type ReportListenerFunc

type ReportListenerFunc func(reportID byte, data []byte)

func (ReportListenerFunc) Report

func (f ReportListenerFunc) Report(reportID byte, data []byte)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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