makeybutton

package
v0.0.0-...-7691dab Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package makeybutton providers a driver for a button that can be triggered by anything that is conductive by using an ultra high value resistor.

Inspired by the amazing MakeyMakey https://makeymakey.com/

This code is a reinterpretation of https://github.com/sparkfun/MaKeyMaKey/blob/master/firmware/Arduino/makey_makey/makey_makey.ino

Index

Constants

View Source
const (
	NeverPressed ButtonState = 0
	Press                    = 1
	Release                  = 2
)
View Source
const (
	NotChanged ButtonEvent = 0
	Pressed                = 1
	Released               = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

Buffer is a buffer to keep track of the most recent readings for a button. in bit form.

func NewBuffer

func NewBuffer() *Buffer

NewBuffer returns a new buffer.

func (*Buffer) Put

func (b *Buffer) Put(val bool)

Put stores a boolean button state into the buffer.

func (*Buffer) Sum

func (b *Buffer) Sum() int

Sum returns the sum of all measurements

type Button

type Button struct {
	HighMeansPressed bool
	// contains filtered or unexported fields
}

Button is a "button"-like device that acts like a MakeyMakey.

func NewButton

func NewButton(pin machine.Pin) *Button

NewButton creates a new Button.

func (*Button) Configure

func (b *Button) Configure() error

Configure configures the Makey Button pin to have the correct settings to detect touches.

func (*Button) Get

func (b *Button) Get() ButtonEvent

Get returns a ButtonEvent based on the most recent state of the button, and if it has changed by being pressed or released.

type ButtonEvent

type ButtonEvent int

ButtonEvent represents when the state of a Button changes.

type ButtonState

type ButtonState int

ButtonState represents the state of a MakeyButton.

Jump to

Keyboard shortcuts

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