keys

package
v0.0.0-...-86f3bae Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KeyPressedThreshold = time.Millisecond * 700

KeyPressedThreshold defines how long a key must be hold down to enter Pressed state

View Source
var PollInterval = time.Millisecond * 30

PollInterval defined how long to pause before reading new key states

Functions

func NewEventChannel

func NewEventChannel(ctx context.Context, pins Pins) <-chan Event

Creates an event channel to which state changes will be sent when a key is pressed or released. Ensure that rpio.Open is called before using this

Types

type Event

type Event struct {
	State State
	Key   Key
}

Event contains key and it's current state

type Key

type Key int

Key defines a type for keys

const (
	Key1 Key = iota
	Key2
	Key3
	Key4
)

type Pins

type Pins struct {
	Key1 pin.KeyPin
	Key2 pin.KeyPin
	Key3 pin.KeyPin
	Key4 pin.KeyPin
}

type State

type State int

possible states are

Down - key was pressed Pressed - key was pressed and hold for at least KeyPressedThreshold Clicked - key was pressed and released before KeyPressedThreshold Released - key was pressed and released

State changes are Down -> Clicked -> EventRelease Down -> Pressed -> EventRelease

const (
	Down State = iota
	Pressed
	Clicked
	Released
	PressedReleased
)

Jump to

Keyboard shortcuts

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