touchscreen

package module
v0.0.0-...-8c8de2a Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2020 License: MIT Imports: 4 Imported by: 0

README

FTXXXX_Touchscreen_Driver

Go bindings for touchscreen implementations for FT62xx and FT5x06 touchscreens

Usage

Get the library into your GOPATH

go get github.com/electrocatstudios/FTXXX_Touchscreen_Driver

Then in your file include the following:

import touchscreen "github.com/electrocatstudios/FTXXXX_Touchscreen_Driver"

Code Example

t := touchscreen.Touchscreen{}
t.Init()

numTouches, _ := t.GetTouchesCount()
if numTouches > 0 {
    touch, _ := t.GetTouches()
    fmt.Printf("X: %d, Y: %d\n", touch.X, touch.Y)
}

Note on coordinates

It may be necessary to translate the points received. The position of the points is presented in portrait mode so you may need to rotate depending on your screen orientation. On the ili9341 (FT62XX) screen in landscape mode (for example) the points are as follows:

(0,320)                   (0,0)
X-------------------------X
|                         |
|                         |
|                         |
|                         |
|                         |
X-------------------------X
(240,320)                 (240,0)

For the official Raspberry Pi touchscreen (FT5X06) the coordinates are as follows:

(0,0)                   (800,0)
X-------------------------X
|                         |
|                         |
|                         |
|                         |
|                         |
X-------------------------X
(0,480)                 (800,480)

Features and Requests

If you would like to request any other touchscreen support please email hello@electrocatstudios.com, ideally if you can try and find the datasheet for the controller that would help a lot.

Documentation

Index

Constants

View Source
const (
	MOVE_UP         = 0x10
	MOVE_LEFT       = 0x14
	MOVE_DOWN       = 0x18
	MOVE_RIGHT      = 0x1c
	ZOOM_IN         = 0x48
	ZOOM_OUT        = 0x49
	NO_GESTURE      = 0x00
	GESTURE_UNKNOWN = 0xff
)
View Source
const (
	FT62XX = 1 + iota
	FT5X06
)
View Source
const FT5X06_ADDR = 0x38
View Source
const FT5X06_GESTURE_ADDR = 0x01
View Source
const FT5X06_REG_CHIP_VENDID = 0xA3
View Source
const FT5X06_REG_CTPMVENDID = 0xA8
View Source
const FT5X06_THRESHOLD_ADDR = 0x80
View Source
const FT5X06_TOUCH_COUNT_REG = 0x02
View Source
const FT5X06_TOUCH_VAL_REG = 0x03
View Source
const FT62XX_ADDR = 0x38
View Source
const FT62XX_GESTURE_ADDR = 0x01
View Source
const FT62XX_REG_CHIP_VENDID = 0xA3
View Source
const FT62XX_REG_CTPMVENDID = 0xA8
View Source
const FT62XX_THRESHOLD_ADDR = 0x80
View Source
const FT62XX_TOUCH_COUNT_REG = 0x02
View Source
const FT62XX_TOUCH_VAL_REG = 0x03

Variables

This section is empty.

Functions

This section is empty.

Types

type Gesture

type Gesture int

type TouchPoint

type TouchPoint struct {
	X int
	Y int
}

type TouchScreen

type TouchScreen struct {
	Device           *i2c.Device
	Touched          bool
	LastScreenChange time.Time
	Debug            bool
	TType            Touchscreen_Type
}

func (*TouchScreen) GetCTPMVendorId

func (t *TouchScreen) GetCTPMVendorId() (byte, error)

func (*TouchScreen) GetGestureType

func (t *TouchScreen) GetGestureType() (Gesture, error)

func (*TouchScreen) GetTouches

func (t *TouchScreen) GetTouches() (TouchPoint, error)

Get the touch point of the first touch NOTE: Only supports one touch at the moment

func (*TouchScreen) GetTouchesCount

func (t *TouchScreen) GetTouchesCount() (int, error)

Get the numer of touches the device currently has or 0 if we've already sent this one

func (*TouchScreen) GetVendorID

func (t *TouchScreen) GetVendorID() (byte, error)

func (*TouchScreen) Init

func (t *TouchScreen) Init(tt Touchscreen_Type) error

func (*TouchScreen) SetThreshold

func (t *TouchScreen) SetThreshold() error

type Touchscreen_Type

type Touchscreen_Type int

Jump to

Keyboard shortcuts

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