capacitive

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

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

func NewArray

func NewArray(pins []machine.Pin) *Array

Create a new array of pins to be used as touch sensors. The pins do not need to be initialized. The array is immediately ready to use.

By default, NewArray configures a static threshold that is not very sensitive. If you want the touch inputs to be more sensitive, use SetDynamicThreshold.

func (*Array) RawValue

func (a *Array) RawValue(index int) int

Return the raw value of the given pin index of the most recent call to Update. This value is not smoothed in any way.

func (*Array) SetDynamicThreshold

func (a *Array) SetDynamicThreshold(sensitivity int)

Use a dynamic threshold (as promille), that will calibrate automatically. This is needed when you want to be able to detect touches through a non-conducting surface for example. Something like 100‰ (10%) will probably work in many cases, though you may need to try different value to reliably detect touches.

func (*Array) SetStaticThreshold

func (a *Array) SetStaticThreshold(threshold int)

Use a static threshold. This works well on simple touch surfaces where you'll directly touch the metal.

func (*Array) SmoothedValue

func (a *Array) SmoothedValue(index int) int

Return the value from the moving average. This value is only available when a dynamic threshold has been set, it will panic otherwise.

func (*Array) Touching

func (a *Array) Touching(index int) bool

Return whether the given pin index is currently being touched.

func (*Array) Update

func (a *Array) Update()

Measure all GPIO pins. This function must be called very often, ideally about 100-200 times per second (it will delay a bit when called more than 200 times per second).

Jump to

Keyboard shortcuts

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