# Pythonion
## Description
`Pythonion` is a Python library used to interface to `TernionEAI` firmware running on `Ternion` microcontroller board.
It provides a high level interface to interact with the board and its peripherals.
*Note:* The project is still in development and tested on `Windows OS` only.
## Installation
### Step 1
Create a new environment with the required dependencies.
```
python -m venv .venv.ternion
```
### Step 2
Activate the environment.
```
.venv.ternion/Scripts/activate
```
### Step 3
Install the `pythonion` package.
```
python -m pip install pythonion
```
## Usage
Create a new script, import the `pythonion` package and use it as shown in the following examples.
### Example 1
```py
""" Get Firmware Info and Serial Number """
from pythonion import Ternion
ptn = Ternion()
print(f"Firmware Info: {ptn.get_firmware_info()}")
print(f"Serial Number: {ptn.get_serial_number()}")
ptn.start()
```
### Example 2
```python
"""
Testing:
- Make an analog input change to see the event data
- Press a switch to see the event data
"""
from pythonion import Ternion, TernionSwitchEventData, TernionAnalogEventData
def psw_event_callback(event: TernionSwitchEventData) -> None:
print(f"{event.get_producer()} {event.get_state_name()} {event.get_press_count()}")
def adc_event_callback(event: TernionAnalogEventData) -> None:
print(f"{event.get_producer()} {event.get_voltage():.3f}")
pyt = Ternion()
pyt.on_switch_event(psw_event_callback)
pyt.on_analog_event(adc_event_callback)
pyt.start()
```
Raw data
{
"_id": null,
"home_page": "https://github.com/drsanti/pythonion",
"name": "pythonion",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Ternion Development Team",
"author_email": "santi.inc.kmutt@example.com",
"download_url": "https://files.pythonhosted.org/packages/c1/6e/b5b01f1711ecbcfe648bd6a7cec2ab9a917feb1235a0bba04eeb6a451e18/pythonion-0.0.17.tar.gz",
"platform": null,
"description": "# Pythonion\r\n\r\n## Description\r\n\r\n`Pythonion` is a Python library used to interface to `TernionEAI` firmware running on `Ternion` microcontroller board.\r\nIt provides a high level interface to interact with the board and its peripherals.\r\n\r\n*Note:* The project is still in development and tested on `Windows OS` only.\r\n\r\n\r\n## Installation\r\n\r\n\r\n### Step 1\r\n\r\nCreate a new environment with the required dependencies.\r\n\r\n```\r\npython -m venv .venv.ternion\r\n```\r\n\r\n### Step 2\r\n\r\nActivate the environment.\r\n\r\n```\r\n.venv.ternion/Scripts/activate\r\n```\r\n\r\n### Step 3\r\n\r\nInstall the `pythonion` package.\r\n\r\n```\r\npython -m pip install pythonion\r\n```\r\n\r\n## Usage\r\n\r\nCreate a new script, import the `pythonion` package and use it as shown in the following examples.\r\n\r\n### Example 1\r\n\r\n```py\r\n\"\"\" Get Firmware Info and Serial Number \"\"\"\r\n\r\nfrom pythonion import Ternion\r\n\r\nptn = Ternion()\r\nprint(f\"Firmware Info: {ptn.get_firmware_info()}\")\r\nprint(f\"Serial Number: {ptn.get_serial_number()}\")\r\nptn.start()\r\n\r\n```\r\n\r\n### Example 2\r\n```python\r\n\"\"\"\r\nTesting:\r\n - Make an analog input change to see the event data\r\n - Press a switch to see the event data\r\n\"\"\"\r\n\r\nfrom pythonion import Ternion, TernionSwitchEventData, TernionAnalogEventData\r\n\r\n\r\ndef psw_event_callback(event: TernionSwitchEventData) -> None:\r\n print(f\"{event.get_producer()} {event.get_state_name()} {event.get_press_count()}\")\r\n\r\n\r\ndef adc_event_callback(event: TernionAnalogEventData) -> None:\r\n print(f\"{event.get_producer()} {event.get_voltage():.3f}\")\r\n\r\n\r\npyt = Ternion()\r\npyt.on_switch_event(psw_event_callback)\r\npyt.on_analog_event(adc_event_callback)\r\npyt.start()\r\n\r\n```\r\n",
"bugtrack_url": null,
"license": null,
"summary": "Python package for Ternion microcontroller board",
"version": "0.0.17",
"project_urls": {
"Homepage": "https://github.com/drsanti/pythonion"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "930aaa6779072a501a39ce853f9cefe155ee28028893584c582e5fcc1383f368",
"md5": "b4ef7857d3590b67c7e165397fe8612e",
"sha256": "2e086995dbe9e6c578bae4b51c851c300c5f614a4ba7d0fe5cb4ac675b731785"
},
"downloads": -1,
"filename": "pythonion-0.0.17-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b4ef7857d3590b67c7e165397fe8612e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 56549,
"upload_time": "2024-07-05T02:41:31",
"upload_time_iso_8601": "2024-07-05T02:41:31.785087Z",
"url": "https://files.pythonhosted.org/packages/93/0a/aa6779072a501a39ce853f9cefe155ee28028893584c582e5fcc1383f368/pythonion-0.0.17-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c16eb5b01f1711ecbcfe648bd6a7cec2ab9a917feb1235a0bba04eeb6a451e18",
"md5": "80f8e2a2f86b28b42a457dd9afefcc51",
"sha256": "f1ff8e57dd0a5ca7b7a6656cc63132d5dc4cd515147dfa46e750c1fbd9ebdf75"
},
"downloads": -1,
"filename": "pythonion-0.0.17.tar.gz",
"has_sig": false,
"md5_digest": "80f8e2a2f86b28b42a457dd9afefcc51",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 50312,
"upload_time": "2024-07-05T02:41:33",
"upload_time_iso_8601": "2024-07-05T02:41:33.439466Z",
"url": "https://files.pythonhosted.org/packages/c1/6e/b5b01f1711ecbcfe648bd6a7cec2ab9a917feb1235a0bba04eeb6a451e18/pythonion-0.0.17.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-05 02:41:33",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "drsanti",
"github_project": "pythonion",
"github_not_found": true,
"lcname": "pythonion"
}