Skip to content

Commit

Permalink
SDK Partially Ported. Much more work needed
Browse files Browse the repository at this point in the history
  • Loading branch information
fchorney committed Mar 11, 2024
1 parent bb42844 commit a8ef0a4
Show file tree
Hide file tree
Showing 21 changed files with 1,298 additions and 56 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
- uses: actions/checkout@v2

# Set up python
- name: Set up Python 3.x
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: 3.x
python-version: 3.10

# Install Deps
- name: Install dependencies
Expand All @@ -25,12 +25,12 @@ jobs:
- name: Run Code Linters
run: tox -e check

test:

test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9]
python-version: [3.10]
steps:
# Checkout Repo
- uses: actions/checkout@v2
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
with:
name: coverage_${{ matrix.python-version }}
path: .coverage.*

coverage:
needs: test
runs-on: ubuntu-latest
Expand All @@ -69,10 +69,10 @@ jobs:
- uses: actions/checkout@v2

# Set up python
- name: Set up Python 3.x
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: 3.x
python-version: 3.10

# Install Deps
- name: Install Dependencies
Expand Down
70 changes: 69 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,78 @@
# pySMX
[![Build Status](https://github.com/fchorney/pysmx/workflows/build/badge.svg)](https://github.com/fchorney/pysmx/actions?query=workflow:build)
[![Python Version](https://img.shields.io/badge/python-3.8%20%7C%203.9-blue.svg)](https://www.python.org/)
[![Python Version](https://img.shields.io/badge/python-3.8%20%7C%203.10-blue.svg)](https://www.python.org/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)

StepManiaX SDK for Python

## Status

Currently fairly incomplete. A lot of core functionality exists, but the rest of the SDK needs to be finished. At some point I can write out a list
of functions currently enabled and which ones have yet to be added.

## Installation (macOS)

These are the instructions that I have been using to run this on my system so far.

1. Use pyenv to install Python 3.10.x or use System Python if its 3.10.x or greater (This will probably work on newer pythons, but I don't know personally).
2. Use [Homebrew](https://brew.sh/) to install `libusb`

```
brew install libusb
```

3. Make sure to add the following lines to your `~/.zshrc` or `~/.bashrc`

```
# LibUSB Settings
export DYLD_LIBRARY_PATH=/opt/homebrew/lib
```

4. Maybe restart here just to make sure everything is installed properly
5. Download this repo onto your macOS system somewhere
6. Inside this repo set up a python venv, activate it, and install the software into the venv

```
python -m venv venv
. venv/bin/activate
pip install --upgrade pip
pip install -e .
```
7. Now you can play around with the code. The following script will show you the configs for the 2 connected pads. If you have just one, leave out the last line:

```
from pysmx.sdk.api import SMXAPI
smxapi = SMXAPI()
print(smxapi.get_stage_config(1))
print(smxapi_get_stage_config(2))
```

8. Run your script with `python script_name.py`. This assumes you have the `venv` still activated.

## Using pySMX to set your stage settings without needing to connect to a windows computer

As this API/SDK is still unfinished, you can use the included script to set your stages sensor values to whatever you want.

Following the above instructions to set this repo up and use the code, you can then do the following.

1. Modify the `set_stage_configs.py` python file to your specified SMX Config.
2. What you want to look at is the `sensor_data` array. Assuming you are on an FSR you want to look at the 2:9 values in the array. These
correspond to the 4 sensor release thresholds, and then the 4 sensor press thresholds.
3. This will set the same settings for all 9 panels. If you need to modify each panel individually, you will have to modify the code that sets
`itl_config.panel_settings` to supply 9 `PackedSensorSettings` objects for the 9 panels. (Left to Right, Top to Bottom).
4. If you need help with this, just reach out and I can probably help.
5. Make sure you have the venv activated and run the script.

```
python set_stage_configs.py
```

## 3rd Party Software

### LibUSB
You need to have `libUSB` installed to run this. I have personally installed it with Homebrew and added `export DYLD_LIBRARY_PATH=/opt/homebrew/lib` to my `zshrc` file.

## License

pysmx is provided under an MIT License.
11 changes: 11 additions & 0 deletions docs/general/gen_cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Cli

Explain SMX Cli Here

### Usage

```eval_rst
.. runcmd:: python ./pysmx/cli.py --help
:syntax: sh
:prompt:
```
11 changes: 0 additions & 11 deletions docs/general/gen_template.md

This file was deleted.

6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[build-system]
requires = ["setuptools", "wheel", "Cython"]

[tool.black]
target-version = ["py39"]
target-version = ["py310"]
line-length=120

[tool.coverage.run]
relative_files = true
Expand Down
21 changes: 1 addition & 20 deletions pysmx/template.py → pysmx/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,14 @@
from loguru import logger


def function_test(x: int) -> int:
"""
Returns the input value multiplied by 2
Args:
x (int): Value to multiply
Returns:
int: input value multiplied by 2
Example:
>>> function_test(2)
4
"""
return x * 2


def main(args: Optional[Sequence[str]] = None):
pargs = parse_args(args=args)
logger.debug(f"Arguments: {pargs}")
logger.info(f"Parsed Args: {pargs}")


def parse_args(args: Optional[Sequence[str]] = None) -> argparse.Namespace:
parser = argparse.ArgumentParser(description="StepManiaX SDK for Python")

parser.add_argument("someargument", help="argument help")

return parser.parse_args(args)


Expand Down
14 changes: 14 additions & 0 deletions pysmx/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class SMXPacketTimeoutError(Exception):
pass


class SMXStageHIDError(Exception):
pass


class SMXStageNotFoundError(Exception):
pass


class SMXRateLimitError(Exception):
pass
Empty file added pysmx/sdk/__init__.py
Empty file.
Loading

0 comments on commit a8ef0a4

Please sign in to comment.