Skip to content

Commit a3a8fe2

Browse files
authored
Merge pull request #1 from acoster/devel
Sync main to version 0.1.0
2 parents 251e3d7 + e0e6c2a commit a3a8fe2

File tree

9 files changed

+392
-120
lines changed

9 files changed

+392
-120
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Alex Coster
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,42 @@
11
# busytag_tool
22

3-
Python library (and soon CLI) to interact with [Busy Tag](https://www.busy-tag.com/) devices via USB,
4-
using its [USB CDC interface]( https://luxafor.helpscoutdocs.com/article/47-busy-tag-usb-cdc-command-reference-guide).
3+
Python library and CLI to interact with [Busy Tag](https://www.busy-tag.com/) devices using
4+
the [USB CDC interface]( https://luxafor.helpscoutdocs.com/article/47-busy-tag-usb-cdc-command-reference-guide).
5+
6+
## Installation
7+
8+
```shell
9+
$ pip install busytag
10+
```
11+
12+
## CLI usage
13+
14+
The first time the tool is used, you should pass the device path through
15+
the flag `--device=/dev/whatever`. This will be saved in `~/.busytag.toml`
16+
and will be used in subsequent runs where `--device` is not passed.
17+
18+
```shell
19+
$ busytag-tool
20+
Available commands:
21+
help: Prints this message
22+
info: Displays device information
23+
list_pictures: Lists pictures in device
24+
list_files: Lists files in device
25+
get_picture: Gets the filename of the picture being shown
26+
set_picture <filename>: Sets the picture shown in the device
27+
put <filename>: Uploads <filename>
28+
get <filename>: Copies <filename> from the device to the working directory
29+
rm <filename>: Deletes <filename>
30+
set_led_solid_color <6 hex RGB colour>: Sets the LEDs colour
31+
get_brightness: Gets current display brightness
32+
set_brightness <brightness>: Sets current display brightness (int between 1 and 100, inclusive
33+
```
34+
35+
## API usage
36+
37+
```python
38+
from busytag import Device
39+
40+
bt = Device('/dev/fooBar')
41+
bt.set_active_picture('coding.gif')
42+
```

pyproject.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[project]
2+
name = "busytag"
3+
version = "0.1.0"
4+
dynamic = ["dependencies"]
5+
authors = [{ name = "Alex Coster", email = "[email protected]" }]
6+
description = "A library and CLI tool to control Busy Tag devices."
7+
readme = "README.md"
8+
requires-python = ">=3.11"
9+
license = "MIT"
10+
license-files = ["LICENSE"]
11+
classifiers = [
12+
"Development Status :: 2 - Pre-Alpha",
13+
"Environment :: Console",
14+
"Operating System :: OS Independent"
15+
]
16+
17+
[project.scripts]
18+
busytag-tool = "busytag.tool:run_main"
19+
20+
[project.urls]
21+
Homepage = "https://github.com/acoster/busytag_tool"
22+
Issues = "https://github.com/acoster/busytag_tool/issues"
23+
Repository = "https://github.com/acoster/busytag_tool.git"
24+
25+
[build-system]
26+
requires = ["hatchling >= 1.26", "hatch-requirements-txt"]
27+
build-backend = "hatchling.build"
28+
29+
[tool.hatch.metadata.hooks.requirements_txt]
30+
files = ["requirements.txt"]

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
-i https://pypi.org/simple
2-
pyserial~=3.5
2+
absl-py~=2.1.0
3+
pyserial~=3.5
4+
tomlkit~=0.13.2

src/busytag/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# SPDX-License-Identifier: MIT
2+
3+
from .device import Device
4+
from .types import *

src/busytag/config.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# SPDX-License-Identifier: MIT
2+
3+
import tomlkit
4+
import os.path
5+
6+
from .types import *
7+
8+
from typing import Optional, Sequence
9+
10+
class ToolConfig(object):
11+
def __init__(self, path: Optional[str] = None):
12+
self.device = None
13+
self.path = path
14+
if path is not None:
15+
self.path = os.path.expanduser(path)
16+
if os.path.exists(self.path):
17+
self.__load_from_file()
18+
19+
20+
def write_to_file(self):
21+
assert self.path is not None
22+
conf = {}
23+
if self.device is not None:
24+
conf['device'] = self.device
25+
with open(self.path, "w") as fp:
26+
tomlkit.dump(conf, fp)
27+
28+
def __load_from_file(self):
29+
with open(self.path, 'rb') as fp:
30+
conf = tomlkit.load(fp)
31+
self.device = conf['device']

0 commit comments

Comments
 (0)