toypad

package
v0.0.0-...-bc0575e Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VendorID  = 0x0e6f
	ProductID = 0x0241
)

Variables

View Source
var (
	ErrFrameInvalidLength   = errors.New("invalid frame length")
	ErrFrameInvalidChecksum = errors.New("invalid frame checksum")
)

Functions

This section is empty.

Types

type Command

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

Command is a command to send to the toy pad.

func Flash

func Flash(pad Pad, ticksOn uint8, ticksOff uint8, ticksCount uint8, color RGB) *Command

func SetColor

func SetColor(pad Pad, color RGB) *Command

func TagModel

func TagModel(index uint8, data []byte, cb func(data []byte, err error)) *Command

func TagRead

func TagRead(index uint8, pageNum uint8, cb func(status uint8, data []byte, err error)) *Command

func Wake

func Wake() *Command

func (*Command) Format

func (cmd *Command) Format(f fmt.State, c rune)

Format implements fmt.Formatter.

func (*Command) Send

func (c *Command) Send(w io.Writer, msgId uint8) error

type Event

type Event struct {
	Pad    Pad
	X      uint8 // Unknown data
	Index  uint8
	Action TagAction
	UID    UID
}

func (*Event) Format

func (ev *Event) Format(f fmt.State, c rune)

type Pad

type Pad uint8

Pad is one area (or all) of the Toy Pad.

const (
	AllPads   Pad = 0
	CenterPad Pad = 1
	LeftPad   Pad = 2
	RightPad  Pad = 3
)

type RGB

type RGB struct {
	R, G, B uint8
}

RGB is a color.

type TagAction

type TagAction uint8

TagAction represents the kind of event happenning related to a tag on the toypad.

const (
	Add    TagAction = 0 // Add happens when a tag is placed on the toypad.
	Remove TagAction = 1 // Remove happends when a tag is removed from the toypad.
)

func (TagAction) String

func (a TagAction) String() string

type ToyPad

type ToyPad struct {
	Events <-chan *Event
	Errors <-chan error
	// contains filtered or unexported fields
}

func NewToyPad

func NewToyPad(r io.Reader, w io.Writer) (*ToyPad, error)

func (*ToyPad) Send

func (tp *ToyPad) Send(cmd *Command) error

type UID

type UID [7]byte

func (UID) String

func (uid UID) String() string

Jump to

Keyboard shortcuts

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