Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Tests
Comment thread
sastraxi marked this conversation as resolved.

on:
push:
branches: [pistomp-v3]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Install uv
uses: astral-sh/setup-uv@v8.1.0

- name: Set up Python
run: uv python install

- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential libasound2-dev libjack-dev pkg-config

- name: Install dependencies
run: uv sync --group dev

- name: Run tests
run: uv run pytest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
__pycache__
*~
.DS_Store
.coverage
1 change: 1 addition & 0 deletions GEMINI.md
37 changes: 35 additions & 2 deletions GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,47 @@ sshfs pistomp@pistomp.local:/home/pistomp <LOCAL_DIR> -o defer_permissions -o vo
- **Pedalboards**: `/home/pistomp/data/.pedalboards/`
- **Service**: `/lib/systemd/system/mod-ala-pi-stomp.service`

## Testing Changes
## Automated Tests

### Running tests

```bash
uv run pytest # run all tests
uv run pytest --snapshot-update # accept new LCD snapshots as baselines
uv run pytest --cov=pistomp --cov=modalapi --cov=common --cov=uilib --cov-report=term-missing
```

### Snapshot fixture

By using the `snapshot` fixture, we can assert that the image rendered to the LCD
does not change unexpectedly.

```python
def test_my_flow(v3_system, snapshot):
# ... drive interactions ...
snapshot() # auto-numbered: snapshots/v3/test_my_file/test_my_flow/0.png
snapshot("label") # named: snapshots/v3/test_my_file/test_my_flow/label.png
snapshot("label") # same label → asserts screen returned to that earlier state
```

Regenerate baselines after intentional UI changes with `--snapshot-update`.

### Adding coverage for a new hardware version

1. Add `tests/v1/conftest.py` (or `v2/`) with a fixture analogous to `v3_system`
using the correct handler (`mod.py`) and hardware class.
2. Mirror the `v3/` file structure — one file per concern, under 500 lines each.
3. Reuse `make_plugin`, `make_parameter`, and `get_urls` from the root conftest or
define version-specific variants in the new `conftest.py`.

## On-device Testing
```bash
# Test pedalboard switch via API
curl -X POST http://localhost:80/pedalboard/load_bundle/ \
-d 'bundlepath=/home/pistomp/data/.pedalboards/AmpBud.pedalboard'
```

# List pedalboards
```bash
curl -s http://localhost:80/pedalboard/list | python3 -m json.tool
```

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ You can start with a base RPi image and use these
but note that the setup scripts have not been updated to work with the newer v3 hardware so you are on your own there.
Also keep in mind that there are hundreds of packages used to build the system.
Package version incompatibilities are much more likely using this method.

## Running tests

Run tests using `pytest` in the virtual environment. There is a Github Actions workflow that runs this in CI as well.

If you are writing new snapshot tests, or experiencing unexpected snapshot assertion failures, try running `pytest --snapshot-update` and inspect the diff. Sometimes there are cross-platform differences; use PIL tweaks in `conftest.py` to align them.
Binary file added fonts/DejaVuSans-Bold.ttf
Binary file not shown.
Binary file added fonts/DejaVuSans.ttf
Binary file not shown.
Binary file added fonts/DejaVuSansMono-Bold.ttf
Binary file not shown.
Binary file added fonts/DejaVuSansMono.ttf
Binary file not shown.
187 changes: 187 additions & 0 deletions fonts/LICENSE-DejaVu.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below)


Bitstream Vera Fonts Copyright
------------------------------

Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
a trademark of Bitstream, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of the fonts accompanying this license ("Fonts") and associated
documentation files (the "Font Software"), to reproduce and distribute the
Font Software, including without limitation the rights to use, copy, merge,
publish, distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to the
following conditions:

The above copyright and trademark notices and this permission notice shall
be included in all copies of one or more of the Font Software typefaces.

The Font Software may be modified, altered, or added to, and in particular
the designs of glyphs or characters in the Fonts may be modified and
additional glyphs or characters may be added to the Fonts, only if the fonts
are renamed to names not containing either the words "Bitstream" or the word
"Vera".

This License becomes null and void to the extent applicable to Fonts or Font
Software that has been modified and is distributed under the "Bitstream
Vera" names.

The Font Software may be sold as part of a larger software package but no
copy of one or more of the Font Software typefaces may be sold by itself.

THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
FONT SOFTWARE.

Except as contained in this notice, the names of Gnome, the Gnome
Foundation, and Bitstream Inc., shall not be used in advertising or
otherwise to promote the sale, use or other dealings in this Font Software
without prior written authorization from the Gnome Foundation or Bitstream
Inc., respectively. For further information, contact: fonts at gnome dot
org.

Arev Fonts Copyright
------------------------------

Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining
a copy of the fonts accompanying this license ("Fonts") and
associated documentation files (the "Font Software"), to reproduce
and distribute the modifications to the Bitstream Vera Font Software,
including without limitation the rights to use, copy, merge, publish,
distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to
the following conditions:

The above copyright and trademark notices and this permission notice
shall be included in all copies of one or more of the Font Software
typefaces.

The Font Software may be modified, altered, or added to, and in
particular the designs of glyphs or characters in the Fonts may be
modified and additional glyphs or characters may be added to the
Fonts, only if the fonts are renamed to names not containing either
the words "Tavmjong Bah" or the word "Arev".

This License becomes null and void to the extent applicable to Fonts
or Font Software that has been modified and is distributed under the
"Tavmjong Bah Arev" names.

The Font Software may be sold as part of a larger software package but
no copy of one or more of the Font Software typefaces may be sold by
itself.

THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Except as contained in this notice, the name of Tavmjong Bah shall not
be used in advertising or otherwise to promote the sale, use or other
dealings in this Font Software without prior written authorization
from Tavmjong Bah. For further information, contact: tavmjong @ free
. fr.

TeX Gyre DJV Math
-----------------
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.

Math extensions done by B. Jackowski, P. Strzelczyk and P. Pianowski
(on behalf of TeX users groups) are in public domain.

Letters imported from Euler Fraktur from AMSfonts are (c) American
Mathematical Society (see below).
Bitstream Vera Fonts Copyright
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera
is a trademark of Bitstream, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of the fonts accompanying this license (“Fonts”) and associated
documentation
files (the “Font Software”), to reproduce and distribute the Font Software,
including without limitation the rights to use, copy, merge, publish,
distribute,
and/or sell copies of the Font Software, and to permit persons to whom
the Font Software is furnished to do so, subject to the following
conditions:

The above copyright and trademark notices and this permission notice
shall be
included in all copies of one or more of the Font Software typefaces.

The Font Software may be modified, altered, or added to, and in particular
the designs of glyphs or characters in the Fonts may be modified and
additional
glyphs or characters may be added to the Fonts, only if the fonts are
renamed
to names not containing either the words “Bitstream” or the word “Vera”.

This License becomes null and void to the extent applicable to Fonts or
Font Software
that has been modified and is distributed under the “Bitstream Vera”
names.

The Font Software may be sold as part of a larger software package but
no copy
of one or more of the Font Software typefaces may be sold by itself.

THE FONT SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
FOUNDATION
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL,
SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN
ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR
INABILITY TO USE
THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
Except as contained in this notice, the names of GNOME, the GNOME
Foundation,
and Bitstream Inc., shall not be used in advertising or otherwise to promote
the sale, use or other dealings in this Font Software without prior written
authorization from the GNOME Foundation or Bitstream Inc., respectively.
For further information, contact: fonts at gnome dot org.

AMSFonts (v. 2.2) copyright

The PostScript Type 1 implementation of the AMSFonts produced by and
previously distributed by Blue Sky Research and Y&Y, Inc. are now freely
available for general use. This has been accomplished through the
cooperation
of a consortium of scientific publishers with Blue Sky Research and Y&Y.
Members of this consortium include:

Elsevier Science IBM Corporation Society for Industrial and Applied
Mathematics (SIAM) Springer-Verlag American Mathematical Society (AMS)

In order to assure the authenticity of these fonts, copyright will be
held by
the American Mathematical Society. This is not meant to restrict in any way
the legitimate use of the fonts, such as (but not limited to) electronic
distribution of documents containing these fonts, inclusion of these fonts
into other public domain or commercial font collections or computer
applications, use of the outline data to create derivative fonts and/or
faces, etc. However, the AMS does require that the AMS copyright notice be
removed from any derivative versions of the fonts which have been altered in
any way. In addition, to ensure the fidelity of TeX documents using Computer
Modern fonts, Professor Donald Knuth, creator of the Computer Modern faces,
has requested that any alterations which yield different font metrics be
given a different name.

$Id$
6 changes: 4 additions & 2 deletions modalapi/modhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
class Modhandler(Handler):
__single = None

def __init__(self, audiocard, homedir):
def __init__(self, audiocard, homedir, data_dir="/home/pistomp/data"):
logging.info("Init modhandler")
if Modhandler.__single:
raise RuntimeError("Attempt to create second Modhandler singleton", Modhandler.__single)
Expand Down Expand Up @@ -78,7 +78,7 @@ def __init__(self, audiocard, homedir):
# Backup
self.backup_dir = "/media/usb0/backups"
self.backup_file = "pistomp_backup.zip"
self.data_dir = "/home/pistomp/data"
self.data_dir = data_dir

# Banks
self.banks_file = os.path.join(self.data_dir, "banks.json")
Expand Down Expand Up @@ -834,6 +834,8 @@ def get_callback(self, callback_name):
return util.DICT_GET(self.callbacks, callback_name)

def set_mod_tap_tempo(self, bpm):
if bpm is None:
return
url = self.root_uri + "set_bpm"
resp = self._rest_post(url, json={"value": bpm})
if resp is None or resp.status_code != 200:
Expand Down
3 changes: 2 additions & 1 deletion pistomp/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import pistomp.taptempo as taptempo

from abc import ABC, abstractmethod
import pistomp.relay as Relay

Controller = Union[AnalogMidiControl.AnalogMidiControl, EncoderMidiControl.EncoderMidiControl, Footswitch.Footswitch]

Expand All @@ -51,7 +52,7 @@ def __init__(self, default_config, handler, midiout, refresh_callback):
self.midi_channel = 0

# Standard hardware objects (not required to exist)
self.relay = None
self.relay: Relay.Relay | None = None
self.analog_controls: list[AnalogControl] = []
self.encoders = []
self.controllers: dict[str, Controller] = {}
Expand Down
4 changes: 3 additions & 1 deletion pistomp/lcd320x240.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ def draw_analog_assignments(self, controllers):
name = "none"
control_type = Token.EXPRESSION if i == 0 else Token.KNOB # HACK cuz we don't know type of unmapped
color = Category.get_category_color(None)
text_color =color
text_color = color
else:
# Mapped control or Volume
control_type = util.DICT_GET(v, Token.TYPE)
Expand All @@ -738,6 +738,8 @@ def draw_analog_assignments(self, controllers):
category = util.DICT_GET(v, Token.CATEGORY)
text_color = Category.get_category_color(category)
color = self.default_plugin_color
else:
text_color = color
Comment thread
sastraxi marked this conversation as resolved.

if control_type == Token.KNOB:
w = Icon(box=Box.xywh(x, y, 0, 0), text=name, text_color=text_color, parent=self.main_panel, outline=0)
Expand Down
Empty file added tests/__init__.py
Empty file.
Loading