Giter VIP home page Giter VIP logo

l58touch's Introduction

l58_touch.py - L58 Multi-Touch MicroPython Module

Tested on LilyGo-EPD47 T5 E-Paper 4.7" running MicroPython v1.18

Class L58Touch

L58Touch(bus, address):

Initialize the L58Touch controller.

Parameters:
    bus: SoftI2C object
    address: I2C address of the touch controller

Private Methods

_cmd_read(self, write, nbytes):

Write bytearray `write` to the controller then read `nbytes` bytes from the controller
and return the bytearray result.

Parameters:
    write: bytearray to write to the controller
    nbytes: number of bytes to read from the controller

Returns:
    bytearray: result of the read operation

_clear_flags(self):

Clear the touch controller flags

_append_point(self, point, point_data):

Parse `point` from `point_data` and append it to the touch_data list as a tuple.

Parameters:
    point: point number
    point_data: list of bytes from the controller

Format of `touch_data`: (finger, x, y, weight, status)
    finger: order of the point touched
    x: x coordinate of the point touched
    y: y coordinate of the point touched
    weight: weight/pressure of the point touched (1-15)
    status: status of the point touched (3 pressed, 0 released)
        Not all points will report released status during multi-touch.

Public Methods

scan_point(self):

scan the touch controller for touch points and update the touch_data list

Returns:
    int: number of points touched

get_point(self):

Return the last point in the touch_data list.

Point Format: (finger, x, y, weight, status)
    finger: order of the point touched
    x: x coordinate of the point touched
    y: y coordinate of the point touched
    weight: weight/pressure of the point touched (1-15)
    status: status of the point touched (3 pressed, 0 released)
        Not all points will report released status during multi-touch.

sleep(self):

Put the touch controller to sleep

wakeup(self):

Wake up the touch controller.
    Must be called to wake up the controller after sleep.

Example

from time import sleep
from machine import Pin, SoftI2C
import l58_touch

tp = l58_touch.L58Touch(SoftI2C(Pin(14), Pin(15)), 90)
while True:
    for _ in range(tp.scan_point()):
        if touch_point := tp.get_point():
            print(touch_point)
    sleep(0.1)

l58touch's People

Contributors

russhughes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.