teensy-controller 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
6
+ # Ignored default folder with query files
7
+ /queries/
8
+ # Datasource local storage ignored files
9
+ /dataSources/
10
+ /dataSources.local.xml
@@ -0,0 +1,6 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <settings>
3
+ <option name="USE_PROJECT_PROFILE" value="false" />
4
+ <version value="1.0" />
5
+ </settings>
6
+ </component>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="~/Library/Application Support/hatch/env/virtual/teensy-controller/QY2lO_Pz/teensy-controller" project-jdk-type="Python SDK" />
4
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/teensy-controller.iml" filepath="$PROJECT_DIR$/.idea/teensy-controller.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module external.system.id="pyproject.toml" type="PYTHON_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <sourceFolder url="file://$MODULE_DIR$/src" />
6
+ </content>
7
+ <orderEntry type="jdk" jdkName="~/Library/Application Support/hatch/env/virtual/teensy-controller/QY2lO_Pz/teensy-controller" jdkType="Python SDK" />
8
+ <orderEntry type="sourceFolder" forTests="false" />
9
+ </component>
10
+ <component name="PackageRequirementsSettings" />
11
+ <component name="PyDocumentationSettings" />
12
+ <component name="ReSTService" />
13
+ <component name="TestRunnerService" />
14
+ </module>
@@ -0,0 +1,60 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="AutoImportSettings">
4
+ <option name="autoReloadType" value="ALL" />
5
+ </component>
6
+ <component name="ChangeListManager">
7
+ <list default="true" id="7b033b38-c4b3-49d6-81a5-be4e0cd3b252" name="Changes" comment="" />
8
+ <option name="SHOW_DIALOG" value="false" />
9
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
10
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
11
+ <option name="LAST_RESOLUTION" value="IGNORE" />
12
+ </component>
13
+ <component name="FileTemplateManagerImpl">
14
+ <option name="RECENT_TEMPLATES">
15
+ <list>
16
+ <option value="Python Script" />
17
+ </list>
18
+ </option>
19
+ </component>
20
+ <component name="ProjectColorInfo"><![CDATA[{
21
+ "associatedIndex": 2,
22
+ "fromUser": false
23
+ }]]></component>
24
+ <component name="ProjectId" id="3HR7MYv9hY2592tHB1X74pTrvie" />
25
+ <component name="ProjectViewState">
26
+ <option name="hideEmptyMiddlePackages" value="true" />
27
+ <option name="showLibraryContents" value="true" />
28
+ </component>
29
+ <component name="PropertiesComponent"><![CDATA[{
30
+ "keyToString": {
31
+ "ModuleVcsDetector.initialDetectionPerformed": "true",
32
+ "RunOnceActivity.ShowReadmeOnStart": "true",
33
+ "RunOnceActivity.typescript.service.memoryLimit.init": "true",
34
+ "codeWithMe.voiceChat.enabledByDefault": "false",
35
+ "last_opened_file_path": "/Users/aprilward/teensy-controller",
36
+ "nodejs_package_manager_path": "npm"
37
+ }
38
+ }]]></component>
39
+ <component name="SharedIndexes">
40
+ <attachedChunks>
41
+ <set>
42
+ <option value="bundled-python-sdk-6fa658e1df1a-5bd6d13a2a75-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-262.8665.369" />
43
+ </set>
44
+ </attachedChunks>
45
+ </component>
46
+ <component name="TaskManager">
47
+ <task active="true" id="Default" summary="Default task">
48
+ <changelist id="7b033b38-c4b3-49d6-81a5-be4e0cd3b252" name="Changes" comment="" />
49
+ <created>1785818979191</created>
50
+ <option name="number" value="Default" />
51
+ <option name="presentableId" value="Default" />
52
+ <updated>1785818979191</updated>
53
+ <workItem from="1785818980352" duration="763000" />
54
+ </task>
55
+ <servers />
56
+ </component>
57
+ <component name="TypeScriptGeneratedFilesManager">
58
+ <option name="version" value="3" />
59
+ </component>
60
+ </project>
@@ -0,0 +1,18 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026-present wardalll <wardal@student.unimelb.edu.au>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6
+ associated documentation files (the "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
9
+ following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial
12
+ portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15
+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
16
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.4
2
+ Name: teensy-controller
3
+ Version: 0.0.1
4
+ Project-URL: Documentation, https://github.com/wardalll/teensy-controller#readme
5
+ Project-URL: Issues, https://github.com/wardalll/teensy-controller/issues
6
+ Project-URL: Source, https://github.com/wardalll/teensy-controller
7
+ Author-email: wardalll <wardal@student.unimelb.edu.au>
8
+ License-Expression: MIT
9
+ License-File: LICENSE.txt
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: Implementation :: CPython
18
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
19
+ Requires-Python: >=3.8
20
+ Requires-Dist: pyserial==3.5
21
+ Requires-Dist: textual==8.2.8
22
+ Description-Content-Type: text/markdown
23
+
24
+ # teensy-controller
25
+
26
+ [![PyPI - Version](https://img.shields.io/pypi/v/teensy-controller.svg)](https://pypi.org/project/teensy-controller)
27
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/teensy-controller.svg)](https://pypi.org/project/teensy-controller)
28
+
29
+ -----
30
+
31
+ ## Table of Contents
32
+
33
+ - [Installation](#installation)
34
+ - [License](#license)
35
+
36
+ ## Installation
37
+
38
+ ```console
39
+ pip install teensy-controller
40
+ ```
41
+
42
+ ## License
43
+
44
+ `teensy-controller` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
@@ -0,0 +1,21 @@
1
+ # teensy-controller
2
+
3
+ [![PyPI - Version](https://img.shields.io/pypi/v/teensy-controller.svg)](https://pypi.org/project/teensy-controller)
4
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/teensy-controller.svg)](https://pypi.org/project/teensy-controller)
5
+
6
+ -----
7
+
8
+ ## Table of Contents
9
+
10
+ - [Installation](#installation)
11
+ - [License](#license)
12
+
13
+ ## Installation
14
+
15
+ ```console
16
+ pip install teensy-controller
17
+ ```
18
+
19
+ ## License
20
+
21
+ `teensy-controller` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
@@ -0,0 +1,67 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "teensy-controller"
7
+ dynamic = ["version"]
8
+ description = ''
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = "MIT"
12
+ keywords = []
13
+ authors = [
14
+ { name = "wardalll", email = "wardal@student.unimelb.edu.au" },
15
+ ]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Programming Language :: Python",
19
+ "Programming Language :: Python :: 3.8",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: Implementation :: CPython",
25
+ "Programming Language :: Python :: Implementation :: PyPy",
26
+ ]
27
+ dependencies = [
28
+ "textual==8.2.8",
29
+ "pyserial==3.5"
30
+ ]
31
+
32
+ [project.urls]
33
+ Documentation = "https://github.com/wardalll/teensy-controller#readme"
34
+ Issues = "https://github.com/wardalll/teensy-controller/issues"
35
+ Source = "https://github.com/wardalll/teensy-controller"
36
+
37
+ [tool.hatch.version]
38
+ path = "src/teensy_controller/__about__.py"
39
+
40
+ [tool.hatch.envs.types]
41
+ extra-dependencies = [
42
+ "mypy>=1.0.0",
43
+ ]
44
+ [tool.hatch.envs.types.scripts]
45
+ check = "mypy --install-types --non-interactive {args:src/teensy_controller tests}"
46
+
47
+ [tool.coverage.run]
48
+ source_pkgs = ["teensy_controller", "tests"]
49
+ branch = true
50
+ parallel = true
51
+ omit = [
52
+ "src/teensy_controller/__about__.py",
53
+ ]
54
+
55
+ [tool.coverage.paths]
56
+ teensy_controller = ["src/teensy_controller", "*/teensy-controller/src/teensy_controller"]
57
+ tests = ["tests", "*/teensy-controller/tests"]
58
+
59
+ [tool.coverage.report]
60
+ exclude_lines = [
61
+ "no cov",
62
+ "if __name__ == .__main__.:",
63
+ "if TYPE_CHECKING:",
64
+ ]
65
+
66
+ [project.scripts]
67
+ controller = "teensy_controller.entry_points:controller"
@@ -0,0 +1,4 @@
1
+ # SPDX-FileCopyrightText: 2026-present wardalll <wardal@student.unimelb.edu.au>
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ __version__ = "0.0.1"
@@ -0,0 +1,3 @@
1
+ # SPDX-FileCopyrightText: 2026-present wardalll <wardal@student.unimelb.edu.au>
2
+ #
3
+ # SPDX-License-Identifier: MIT
@@ -0,0 +1,5 @@
1
+ from teensy_controller.teensy_controller import ControllerApp
2
+
3
+ def controller():
4
+ app = ControllerApp()
5
+ app.run()
@@ -0,0 +1,151 @@
1
+ from __future__ import annotations
2
+
3
+ from pickletools import uint8
4
+ from typing import Type
5
+
6
+ from textual import on
7
+ from textual._path import CSSPathType
8
+ from textual.app import App
9
+ from textual.driver import Driver
10
+ from textual.widgets import Button, Input, Label, Static
11
+ import serial
12
+ from textual.containers import Vertical, Horizontal, Grid
13
+ import time
14
+ from textual.events import Key
15
+
16
+
17
+ class ControllerApp(App):
18
+ CSS = """
19
+
20
+ Grid {
21
+ grid-size: 3 3;
22
+ grid-rows: 3;
23
+ grid-columns: 15;
24
+ align: center middle;
25
+ grid-gutter: 1;
26
+ }
27
+
28
+ .control-button {
29
+ content-align: center middle;
30
+ height: 13;
31
+ width: 3;
32
+ }
33
+
34
+ .hidden {
35
+ visibility: hidden;
36
+ }
37
+
38
+ .small-button {
39
+ width: 5;
40
+ min-width: 5;
41
+ height: 3;
42
+ min-height: 3;
43
+ padding: 0;
44
+ content-align: center middle;
45
+ margin-left: 1;
46
+ margin-bottom: 1;
47
+ margin-top: 1;
48
+
49
+ }
50
+
51
+ .small-button:focus {
52
+ text-style: bold; /* no "reverse" */
53
+ }
54
+
55
+ .more-margin {
56
+ margin-bottom: 1;
57
+ margin-top: 1;
58
+ }
59
+
60
+ .controller {
61
+ align: center middle;
62
+ }
63
+ """
64
+
65
+ def __init__(self):
66
+ super().__init__()
67
+ self.bluetooth: serial.Serial | None = None
68
+ self.keyToButton = {
69
+ "w": "up",
70
+ "s": "down",
71
+ "a": "left",
72
+ "d": "right",
73
+ "space": "shoot",
74
+ "q": "quit",
75
+ }
76
+
77
+ def compose(self):
78
+
79
+ yield Button("X", variant="error", classes="small-button", id="quit")
80
+
81
+ # Inputs
82
+ yield Input(placeholder="Type Bluetooth address here")
83
+ yield Label("", id="port_label")
84
+
85
+ # Buttons
86
+ with Grid():
87
+ # row 1
88
+ yield Static(classes="hidden")
89
+ yield Button("Up", variant="primary", id="up", classes="control-button")
90
+ yield Static(classes="hidden")
91
+
92
+ # row 2
93
+ yield Button("Left", variant="primary", id="left", classes="control-button")
94
+ yield Button("Shoot", variant="success", id="shoot", classes="control-button")
95
+ yield Button("Right", variant="primary", id="right", classes="control-button")
96
+
97
+ # row 3
98
+ yield Static(classes="hidden")
99
+ yield Button("Down", variant="primary", id="down", classes="control-button")
100
+ yield Static(classes="hidden")
101
+
102
+ def bluetooth_response(self, key):
103
+ if key == "quit":
104
+ if self.bluetooth is not None and self.bluetooth.is_open:
105
+ self.bluetooth.write(b"0")
106
+ self.bluetooth.flush()
107
+ self.bluetooth.close()
108
+ self.exit()
109
+
110
+ commands = {
111
+ "up": "1",
112
+ "down": "2",
113
+ "left": "3",
114
+ "right": "4",
115
+ "shoot": "5",
116
+ }
117
+ write = commands.get(key)
118
+
119
+ if self.bluetooth is not None and self.bluetooth.is_open and write is not None:
120
+ self.bluetooth.write(write.encode("utf-8"))
121
+
122
+ @on(Input.Submitted)
123
+ def accept_user_input(self):
124
+ input = self.query_one(Input)
125
+ port = input.value
126
+ label = self.query_one("#port_label", Label)
127
+ label.update(port)
128
+ input.value = ""
129
+
130
+ if self.bluetooth is not None and self.bluetooth.is_open:
131
+ self.bluetooth.close()
132
+
133
+ print("Start Bluetooth connection")
134
+ self.bluetooth = serial.Serial(port, 9600, timeout=1)
135
+ print("Connected")
136
+ self.bluetooth.flushInput()
137
+
138
+ def on_key(self, event: Key):
139
+ button_id = self.keyToButton.get(event.key)
140
+ if button_id is not None:
141
+ button = self.query_one("#" + button_id, Button)
142
+ button.press()
143
+ self.bluetooth_response(button_id)
144
+
145
+ def on_button_pressed(self, event):
146
+ self.bluetooth_response(event.button.id)
147
+
148
+
149
+ if __name__ == "__main__":
150
+ app = ControllerApp()
151
+ app.run()
@@ -0,0 +1,3 @@
1
+ # SPDX-FileCopyrightText: 2026-present wardalll <wardal@student.unimelb.edu.au>
2
+ #
3
+ # SPDX-License-Identifier: MIT