{"id":13802616,"url":"https://github.com/Heerkog/MicroPythonTrill","last_synced_at":"2025-05-13T13:32:31.655Z","repository":{"id":215170814,"uuid":"415296693","full_name":"Heerkog/MicroPythonTrill","owner":"Heerkog","description":"Trill touch sensor library for MicroPython.","archived":false,"fork":false,"pushed_at":"2021-10-25T13:48:32.000Z","size":38,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-22T13:31:29.404Z","etag":null,"topics":["bela","micropython","sensor","trill"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Heerkog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-10-09T12:00:32.000Z","updated_at":"2024-03-12T15:25:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"5821c8b5-f48f-4064-8e11-9ef6d935e38d","html_url":"https://github.com/Heerkog/MicroPythonTrill","commit_stats":null,"previous_names":["heerkog/micropythontrill"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Heerkog%2FMicroPythonTrill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Heerkog%2FMicroPythonTrill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Heerkog%2FMicroPythonTrill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Heerkog%2FMicroPythonTrill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Heerkog","download_url":"https://codeload.github.com/Heerkog/MicroPythonTrill/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225229879,"owners_count":17441336,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bela","micropython","sensor","trill"],"created_at":"2024-08-04T00:01:48.628Z","updated_at":"2024-11-18T18:30:29.537Z","avatar_url":"https://github.com/Heerkog.png","language":"Python","readme":"\u003cdiv id=\"top\"\u003e\u003c/div\u003e\n\n\n\u003c!-- PROJECT SHIELDS --\u003e\n[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![GPL License][license-shield]][license-url]\n[![Website][website-shield]][website-url]\n\n\n\n\u003c!-- PROJECT HEADER --\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n\u003ch3 align=\"center\"\u003eMicroPython Trill Sensor Library\u003c/h3\u003e\n\n  \u003cp align=\"center\"\u003e\n    This library offers implementations of Bela's Trill touch sensors for MicroPython.\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\u003cdetails\u003e\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\u003ca href=\"#about-the-project\"\u003eAbout The Project\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contributing\"\u003eContributing\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contact\"\u003eContact\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#acknowledgments\"\u003eAcknowledgments\u003c/a\u003e\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e\n\n\n\n\u003c!-- ABOUT THE PROJECT --\u003e\n## About The Project\nThis library offers implementations of [Bela](https://bela.io/) 's [Trill touch sensors](https://bela.io/products/trill/) for MicroPython.\nThe library has been tested using an ESP32 development board ([TinyPICO](https://tinypico.com)).\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\u003c!-- GETTING STARTED --\u003e\n## Getting Started\n\nTo get a local copy simply clone this repository.\n\n   ```sh\n   git clone https://github.com/heerkog/MicroPythonTrill.git\n   ```\n\nThe repository is structured as followed:\n\n* `LICENSE` the license.\n* `readme.md`\n* `touch.py` touch helper classes.\n* `trill.py` the library classes.\n\nExample implementation:\n\n```\nfrom machine import SoftI2C, Pin\nfrom trill import Square\nfrom touch import Touches2D\n\ni2c = SoftI2C(scl=Pin(I2C_SCL), sda=Pin(I2C_SDA), freq=400000)\n\nsquare = Square(i2c)\n\ndata = square.read()\ntouches = Touches2D(data)\n\nfor touch in touches.getTouches():\n    print(touch)\n```\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- USAGE EXAMPLES --\u003e\n## Usage\n\nThe library consists of two python files with the following classes:\n\nThe file `trill.py` consists of the following six classes with functions:\n\n* `TrillSensor` The generic Trill sensor representation, with functions:\n  * `__init__(i2c, address, mode, sleep=10)` Initializes a generic Trill sensor using the I\u003csup\u003e2\u003c/sup\u003eC bus `i2c`, the I\u003csup\u003e2\u003c/sup\u003eC address `address`, the mode `mode`, and a sleep time between I\u003csup\u003e2\u003c/sup\u003eC commands of `10` ms.\n  * `identify()` Ask the sensor to identify itself and read its type and firmware version.\n  * `get_type()` Get the sensor type.\n  * `get_firmware_version()` Get the sensor firmware version.\n  * `get_size()` Get the size of the sensor as a tuple (x, y).\n  * `get_num_channels()` Get the number of channels of the sensor.\n  * `read()` Read the latest scan value from the sensor.\n  * `set_mode(mode)` Set the sensor mode, as either `trill.MODE_CENTROID`, `trill.MODE_RAW`, `trill.MODE_BASELINE`, or `trill.MODE_DIFF`.\n  * `get_mode()` Get the sensor mode. Returns `None` if mode hasn't been set.\n  * `set_scan_settings(speed=0, resolution=12)` Set the scan speed and resolution (numBits) of the sensor, with speed being a value from 0 to 3, and resolution being a value from 9 to 16.body\n  * `update_baseline()` Update the baseline capacitance values of the sensor.\n  * `set_prescaler(prescaler=8)` Set the prescaler of the sensor, with prescaler being a value from 1 to 8.\n  * `set_noise_threshold(threshold)` Set the noise threshold for the `trill.MODE_CENTROID` and `trill.MODE_DIFF` modes, with threshold being a value from 0 to 255.\n  * `set_IDAC_value(value)` Set the IDAC value of the sensor, with value being a value from 0 to 255.\n  * `set_minimum_touch_size(self, minSize)` Set the minimum registered touch size.\n  * `set_auto_scan_interval(interval=1)` Set the automatic scan interval (used with the EVT pin).\n  * `is_1D()` Returns `True` if the sensor is one-directional.\n  * `is_2D()` Returns `True` if the sensor is two-directional.\n* `Bar` Subclass of `TrillSensor`, implements a Trill Bar sensor.\n  * `__init__(i2c, address=0x20, mode=MODE_CENTROID, sleep=10)` Initializes a Trill Bar sensor using the I\u003csup\u003e2\u003c/sup\u003eC bus `i2c`, the I\u003csup\u003e2\u003c/sup\u003eC address `0x20`, the mode `trill.MODE_CENTROID`, and a sleep time between I\u003csup\u003e2\u003c/sup\u003eC commands of `10` ms.\n* `Square` Subclass of `TrillSensor`, implements a Trill Square sensor.\n  * `__init__(i2c, address=0x28, mode=MODE_CENTROID, sleep=10)` Initializes a Trill Square sensor using the I\u003csup\u003e2\u003c/sup\u003eC bus `i2c`, the I\u003csup\u003e2\u003c/sup\u003eC address `0x28`, the mode `trill.MODE_CENTROID`, and a sleep time between I\u003csup\u003e2\u003c/sup\u003eC commands of `10` ms.\n* `Craft` Subclass of `TrillSensor`, implements a Trill Craft sensor.\n  * `__init__(i2c, address=0x30, mode=MODE_CENTROID, sleep=10)` Initializes a Trill Bar sensor using the I\u003csup\u003e2\u003c/sup\u003eC bus `i2c`, the I\u003csup\u003e2\u003c/sup\u003eC address `0x30`, the mode `trill.MODE_CENTROID`, and a sleep time between I\u003csup\u003e2\u003c/sup\u003eC commands of `10` ms.\n* `Ring` Subclass of `TrillSensor`, implements a Trill Ring sensor.\n  * `__init__(i2c, address=0x38, mode=MODE_CENTROID, sleep=10)` Initializes a Trill Bar sensor using the I\u003csup\u003e2\u003c/sup\u003eC bus `i2c`, the I\u003csup\u003e2\u003c/sup\u003eC address `0x38`, the mode `trill.MODE_CENTROID`, and a sleep time between I\u003csup\u003e2\u003c/sup\u003eC commands of `10` ms.\n* `Hex` Subclass of `TrillSensor`, implements a Trill Hex sensor.\n  * `__init__(i2c, address=0x40, mode=MODE_CENTROID, sleep=10)` Initializes a Trill Bar sensor using the I\u003csup\u003e2\u003c/sup\u003eC bus `i2c`, the I\u003csup\u003e2\u003c/sup\u003eC address `0x40`, the mode `trill.MODE_CENTROID`, and a sleep time between I\u003csup\u003e2\u003c/sup\u003eC commands of `10` ms.\n\nThe file `touch.py` consists of the following three classes with functions:\n\n* `Touches` Implements a helper class to obtain Trill sensor touches from `trill.MODE_CENTROID` data.\n  * `__init__(data)` Converts data read using `trill.MODE_CENTROID` to a list of touches\n  * `get_touches()` Returns a list of touches as tuples.\n  * `get_num_touches()` Returns the number of touches registered.\n  * `get_touch(index)` Returns the touch at `index` as a tuple.\n  * `is_empty()` Returns `True` if no touches are registered.\n* `Touches1D` Subclass of `Touches`, interprets `trill.MODE_CENTROID` data from one-directional sensors.\n  * `__init__(data)` Converts one-directional data read using MODE_CENTROID to a list of touches\n  * `get_touches()` Returns a list of touches as tuples `[(vertical position, touch size), ...]`.\n  * `get_touch(index)` Returns the touch at `index` as a tuple `(vertical position, touch size)`.\n* `Touches2D` Subclass of `Touches`, interprets `trill.MODE_CENTROID` data from two-directional sensors.\n  * `__init__(data)` Converts two-directional data read using MODE_CENTROID to a list of touches\n  * `get_touches()` Returns a list of touches as tuples `[(horizontal position, vertical position, horizontal size, vertical size), ...]`.\n  * `get_touch(index)` Returns the touch at `index` as a tuple `(horizontal position, vertical position, horizontal size, vertical size)`.\n\n\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\u003c!-- CONTRIBUTING --\u003e\n## Contributing\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\nIf you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag \"enhancement\".\nDon't forget to give the project a star! Thanks again!\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- LICENSE --\u003e\n## License\n\nDistributed under the GNU General Public License. See `LICENSE` for more information.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- CONTACT --\u003e\n## Contact\n\nHeerko Groefsema - [@HeerkoG](https://twitter.com/heerkog) - [hgroefsema.nl](https://hgroefsema.nl)\n\nProject Link: [https://github.com/heerkog/MicroPythonTrill](https://github.com/heerkog/MicroPythonTrill)\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- ACKNOWLEDGMENTS --\u003e\n## Acknowledgments\nThe following resources were of interest during development:\n\n* [About Trill](https://learn.bela.io/products/trill/about-trill/)\n* [Trill Arduino](https://github.com/BelaPlatform/Trill-Arduino)  \n* [Mikes Pi Bakery](https://github.com/Grumpy-Mike/Mikes-Pi-Bakery)\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n[contributors-shield]: https://img.shields.io/github/contributors/heerkog/MicroPythonTrill.svg?style=for-the-badge\n[contributors-url]: https://github.com/heerkog/MicroPythonTrill/graphs/contributors\n[forks-shield]: https://img.shields.io/github/forks/heerkog/MicroPythonTrill.svg?style=for-the-badge\n[forks-url]: https://github.com/heerkog/MicroPythonTrill/network/members\n[stars-shield]: https://img.shields.io/github/stars/heerkog/MicroPythonTrill.svg?style=for-the-badge\n[stars-url]: https://github.com/heerkog/MicroPythonTrill/stargazers\n[issues-shield]: https://img.shields.io/github/issues/heerkog/MicroPythonTrill.svg?style=for-the-badge\n[issues-url]: https://github.com/heerkog/MicroPythonTrill/issues\n[license-shield]: https://img.shields.io/github/license/heerkog/MicroPythonTrill.svg?style=for-the-badge\n[license-url]: https://github.com/heerkog/MicroPythonTrill/blob/master/LICENSE.txt\n\n[website-shield]: https://img.shields.io/badge/Website-H-black.svg?style=for-the-badge\u0026colorB=2A638C\n[website-url]: https://hgroefsema.nl\n","funding_links":[],"categories":["Libraries"],"sub_categories":["Sensors"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHeerkog%2FMicroPythonTrill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHeerkog%2FMicroPythonTrill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHeerkog%2FMicroPythonTrill/lists"}